Version Description
- Re-implementation by extending C2C_Plugin_016, which among other things adds support for:
- Reset of options to default values
- Better sanitization of input values
- Offload of core/basic functionality to generic plugin framework
- Additional hooks for various stages/places of plugin operation
- Easier localization support
- Add error checking and reporting when attempting to send test e-mail
- Don't configure the mailer to use SMTP if no host is provided
- Fix localization support
- Store plugin instance in global variable, $c2c_configure_smtp, to allow for external manipulation
- Rename class from 'ConfigureSMTP' to 'c2c_ConfigureSMTP'
- Remove docs from top of plugin file (all that and more are in readme.txt)
- Note compatibility with WP 3.0+
- Minor tweaks to code formatting (spacing)
- Add Upgrade Notice section to readme.txt
- Add PHPDoc documentation
- Add package info to top of file
- Update copyright date
- Remove trailing whitespace
- Update screenshot
- Update .pot file
Download this release
Release Info
Developer | coffee2code |
Plugin | Configure SMTP |
Version | 3.0 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 3.0
- c2c-plugin.php +770 -0
- configure-smtp.php +189 -308
- configure-smtp.pot +137 -74
- readme.txt +36 -3
- screenshot-1.png +0 -0
c2c-plugin.php
ADDED
@@ -0,0 +1,770 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package C2C_Plugins
|
4 |
+
* @author Scott Reilly
|
5 |
+
* @version 016
|
6 |
+
*/
|
7 |
+
/*
|
8 |
+
Basis for other plugins
|
9 |
+
|
10 |
+
Compatible with WordPress 2.8+, 2.9+, 3.0+.
|
11 |
+
|
12 |
+
=>> Read the accompanying readme.txt file for more information. Also, visit the plugin's homepage
|
13 |
+
=>> for more information and the latest updates
|
14 |
+
|
15 |
+
Installation:
|
16 |
+
|
17 |
+
*/
|
18 |
+
|
19 |
+
/*
|
20 |
+
Copyright (c) 2010 by Scott Reilly (aka coffee2code)
|
21 |
+
|
22 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
23 |
+
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
24 |
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
25 |
+
Software is furnished to do so, subject to the following conditions:
|
26 |
+
|
27 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
28 |
+
|
29 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
30 |
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
31 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
32 |
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
33 |
+
*/
|
34 |
+
|
35 |
+
if ( !class_exists( 'C2C_Plugin_016' ) ) :
|
36 |
+
|
37 |
+
class C2C_Plugin_016 {
|
38 |
+
var $plugin_css_version = '006';
|
39 |
+
var $options = array();
|
40 |
+
var $option_names = array();
|
41 |
+
var $required_config = array( 'menu_name', 'name' );
|
42 |
+
var $saved_settings = false;
|
43 |
+
var $saved_settings_msg = '';
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Handles installation tasks, such as ensuring plugin options are instantiated and saved to options table.
|
47 |
+
*
|
48 |
+
* @param string $version Version of the plugin.
|
49 |
+
* @param string $id_base A unique base ID for the plugin (generally a lower-case, dash-separated version of plugin name).
|
50 |
+
* @param string $author_prefix Short (2-3 char) identifier for plugin author.
|
51 |
+
* @param string $file The __FILE__ value for the sub-class.
|
52 |
+
* @param array $plugin_options (optional) Array specifying further customization of plugin configuration.
|
53 |
+
* @return void
|
54 |
+
*/
|
55 |
+
function C2C_Plugin_016( $version, $id_base, $author_prefix, $file, $plugin_options = array() ) {
|
56 |
+
global $pagenow;
|
57 |
+
$id_base = sanitize_title( $id_base );
|
58 |
+
if ( !file_exists( $file ) )
|
59 |
+
die( sprintf( __( 'Invalid file specified for C2C_Plugin: %s', $this->textdomain ), $file ) );
|
60 |
+
|
61 |
+
$u_id_base = str_replace( '-', '_', $id_base );
|
62 |
+
$author_prefix .= '_';
|
63 |
+
$defaults = array(
|
64 |
+
'admin_options_name' => $author_prefix . $u_id_base, // The setting under which all plugin settings are stored under (as array)
|
65 |
+
'config' => array(), // Default configuration
|
66 |
+
'disable_contextual_help' => false, // Prevent overriding of the contextual help?
|
67 |
+
'disable_update_check' => false, // Prevent WP from checking for updates to this plugin?
|
68 |
+
'hook_prefix' => $u_id_base . '_', // Prefix for all hooks
|
69 |
+
'form_name' => $u_id_base, // Name for the <form>
|
70 |
+
'menu_name' => '', // Specify this via plugin
|
71 |
+
'name' => '', // Full, localized version of the plugin name
|
72 |
+
'nonce_field' => 'update-' . $u_id_base, // Nonce field value
|
73 |
+
'settings_page' => 'options-general', // The type of the settings page.
|
74 |
+
'show_admin' => true, // Should admin be shown? Only applies if admin is enabled
|
75 |
+
'textdomain' => $id_base, // Textdomain for localization
|
76 |
+
'textdomain_subdir' => 'lang' // Subdirectory, relative to plugin's root, to hold localization files
|
77 |
+
);
|
78 |
+
$settings = wp_parse_args( $plugin_options, $defaults );
|
79 |
+
|
80 |
+
foreach ( array_keys( $defaults ) as $key )
|
81 |
+
$this->$key = $settings[$key];
|
82 |
+
|
83 |
+
$this->author_prefix = $author_prefix;
|
84 |
+
$this->id_base = $id_base;
|
85 |
+
$this->options_page = ''; // This will be set when the options is created
|
86 |
+
$this->plugin_basename = plugin_basename( $file );
|
87 |
+
$this->plugin_file = $file;
|
88 |
+
$this->plugin_path = plugins_url( '', $file );
|
89 |
+
$this->u_id_base = $u_id_base; // Underscored version of id_base
|
90 |
+
$this->version = $version;
|
91 |
+
|
92 |
+
add_action( 'init', array( &$this, 'init' ) );
|
93 |
+
$plugin_file = implode( '/', array_slice( explode( '/', $this->plugin_basename ), -2 ) );
|
94 |
+
add_action( 'activate_' . $plugin_file, array( &$this, 'install' ) );
|
95 |
+
add_action( 'deactivate_' . $plugin_file, array( &$this, 'deactivate' ) );
|
96 |
+
register_uninstall_hook( $this->plugin_file, array( &$this, 'uninstall' ) );
|
97 |
+
|
98 |
+
add_action( 'admin_init', array( &$this, 'init_options' ) );
|
99 |
+
|
100 |
+
if ( basename( $pagenow, '.php' ) == $this->settings_page )
|
101 |
+
add_action( 'admin_head', array( &$this, 'add_c2c_admin_css' ) );
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Handles installation tasks, such as ensuring plugin options are instantiated and saved to options table.
|
106 |
+
*
|
107 |
+
* This can be overridden.
|
108 |
+
*
|
109 |
+
* @return void
|
110 |
+
*/
|
111 |
+
function install() {
|
112 |
+
$this->options = $this->get_options();
|
113 |
+
update_option( $this->admin_options_name, $this->options );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Handles uninstallation tasks, such as deleting plugin options.
|
118 |
+
*
|
119 |
+
* This can be overridden.
|
120 |
+
*
|
121 |
+
* @return void
|
122 |
+
*/
|
123 |
+
function uninstall() {
|
124 |
+
delete_option( $this->admin_options_name );
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Handles deactivation tasks
|
129 |
+
*
|
130 |
+
* This should be overridden.
|
131 |
+
*
|
132 |
+
* @return void
|
133 |
+
*/
|
134 |
+
function deactivate() { }
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Handles actions to be hooked to 'init' action, such as loading text domain and loading plugin config data array.
|
138 |
+
*
|
139 |
+
* @return void
|
140 |
+
*/
|
141 |
+
function init() {
|
142 |
+
global $c2c_plugin_max_css_version;
|
143 |
+
if ( !isset( $c2c_plugin_max_css_version ) || ( $c2c_plugin_max_css_version < $this->plugin_css_version ) )
|
144 |
+
$c2c_plugin_max_css_version = $this->plugin_css_version;
|
145 |
+
$this->load_textdomain();
|
146 |
+
$this->load_config();
|
147 |
+
$this->verify_config();
|
148 |
+
|
149 |
+
if ( $this->disable_update_check )
|
150 |
+
add_filter( 'http_request_args', array( &$this, 'disable_update_check' ), 5, 2 );
|
151 |
+
|
152 |
+
if ( $this->show_admin && $this->settings_page && !empty( $this->config ) && current_user_can( 'manage_options' ) ) {
|
153 |
+
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
154 |
+
if ( !$this->disable_contextual_help ) {
|
155 |
+
add_action( 'contextual_help', array( &$this, 'contextual_help' ), 10, 3 );
|
156 |
+
if ( $this->is_plugin_admin_page() )
|
157 |
+
add_thickbox();
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
$this->register_filters();
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Prevents this plugin from being included when WordPress phones home
|
166 |
+
* to check for plugin updates.
|
167 |
+
*
|
168 |
+
* @param array $r Response array
|
169 |
+
* @param string $url URL for the update check
|
170 |
+
* @return array The response array with this plugin removed, if present
|
171 |
+
*/
|
172 |
+
function disable_update_check( $r, $url ) {
|
173 |
+
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
|
174 |
+
return $r; // Not a plugin update request. Bail immediately.
|
175 |
+
$plugins = unserialize( $r['body']['plugins'] );
|
176 |
+
unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );
|
177 |
+
unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] );
|
178 |
+
$r['body']['plugins'] = serialize( $plugins );
|
179 |
+
return $r;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Initializes options
|
184 |
+
*
|
185 |
+
* @return void
|
186 |
+
*/
|
187 |
+
function init_options() {
|
188 |
+
register_setting( $this->admin_options_name, $this->admin_options_name, array( &$this, 'sanitize_inputs' ) );
|
189 |
+
add_settings_section( 'default', '', array( &$this, 'draw_default_section' ), $this->plugin_file );
|
190 |
+
add_filter( 'whitelist_options', array( &$this, 'whitelist_options' ) );
|
191 |
+
foreach ( $this->get_option_names( false ) as $opt )
|
192 |
+
add_settings_field( $opt, $this->get_option_label( $opt ), array( &$this, 'display_option' ), $this->plugin_file, 'default', $opt );
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Whitelist the plugin's option(s)
|
197 |
+
*
|
198 |
+
* @param array $options Array of options
|
199 |
+
* @return array The whitelist-amended $options array
|
200 |
+
*/
|
201 |
+
function whitelist_options( $options ) {
|
202 |
+
$added = array( $this->admin_options_name => array( $this->admin_options_name ) );
|
203 |
+
$options = add_option_whitelist( $added, $options );
|
204 |
+
return $options;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Special output for the default section. Can be overridden if desired.
|
209 |
+
*
|
210 |
+
* @return void
|
211 |
+
*/
|
212 |
+
function draw_default_section() { }
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Gets the label for a given option
|
216 |
+
*
|
217 |
+
* @param string $opt The option
|
218 |
+
* @return string The label for the option
|
219 |
+
*/
|
220 |
+
function get_option_label( $opt ) {
|
221 |
+
return isset( $this->config[$opt]['label'] ) ? $this->config[$opt]['label'] : '';
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Resets plugin options
|
226 |
+
*
|
227 |
+
* @return array
|
228 |
+
*/
|
229 |
+
function reset_options() {
|
230 |
+
$options = $this->get_options( false );
|
231 |
+
return $options;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Sanitize user inputs prior to saving
|
236 |
+
*/
|
237 |
+
function sanitize_inputs( $inputs ) {
|
238 |
+
do_action( $this->get_hook( 'before_save_options' ), $this );
|
239 |
+
if ( isset( $_POST['Reset'] ) ) {
|
240 |
+
$options = $this->reset_options();
|
241 |
+
add_settings_error( 'general', 'settings_reset', __( 'Settings reset.', $this->textdomain ), 'updated' );
|
242 |
+
} else {
|
243 |
+
// Start with the existing options, then start overwriting their potential override value. (This prevents
|
244 |
+
// unscrupulous addition of fields by the user)
|
245 |
+
$options = $this->get_options();
|
246 |
+
$option_names = $this->get_option_names();
|
247 |
+
foreach ( $option_names as $opt ) {
|
248 |
+
if ( !isset( $inputs[$opt] ) ) {
|
249 |
+
if ( $this->config[$opt]['input'] == 'checkbox' )
|
250 |
+
$options[$opt] = '';
|
251 |
+
elseif ( ( $this->config[$opt]['required'] === true ) ) {
|
252 |
+
$msg = sprintf( __( 'A value is required for: "%s"', $this->textdomain ), $this->config[$opt]['label'] );
|
253 |
+
add_settings_error( 'general', 'setting_required', $msg, 'error' );
|
254 |
+
}
|
255 |
+
}
|
256 |
+
else {
|
257 |
+
$val = $inputs[$opt];
|
258 |
+
$error = false;
|
259 |
+
if ( empty( $val ) && ( $this->config[$opt]['required'] === true ) ) {
|
260 |
+
$msg = sprintf( __( 'A value is required for: "%s"', $this->textdomain ), $this->config[$opt]['label'] );
|
261 |
+
$error = true;
|
262 |
+
} else {
|
263 |
+
$input = $this->config[$opt]['input'];
|
264 |
+
switch ( $this->config[$opt]['datatype'] ) {
|
265 |
+
case 'checkbox':
|
266 |
+
break;
|
267 |
+
case 'int':
|
268 |
+
if ( !empty( $val ) && ( !is_numeric( $val ) || ( intval( $val ) != round( $val ) ) ) ) {
|
269 |
+
$msg = sprintf( __( 'Expected integer value for: %s', $this->textdomain ), $this->config[$opt]['label'] );
|
270 |
+
$error = true;
|
271 |
+
$val = '';
|
272 |
+
}
|
273 |
+
break;
|
274 |
+
case 'array':
|
275 |
+
if ( empty( $val ) )
|
276 |
+
$val = array();
|
277 |
+
elseif ( $input == 'text' )
|
278 |
+
$val = explode( ',', str_replace( array( ', ', ' ', ',' ), ',', $val ) );
|
279 |
+
else
|
280 |
+
$val = array_map( 'trim', explode( "\n", trim( $val ) ) );
|
281 |
+
break;
|
282 |
+
case 'hash':
|
283 |
+
if ( !empty( $val ) && $input != 'select' ) {
|
284 |
+
$new_values = array();
|
285 |
+
foreach ( explode( "\n", $val ) AS $line ) {
|
286 |
+
list( $shortcut, $text ) = array_map( 'trim', explode( "=>", $line, 2 ) );
|
287 |
+
if ( !empty( $shortcut ) )
|
288 |
+
$new_values[str_replace( '\\', '', $shortcut )] = str_replace( '\\', '', $text );
|
289 |
+
}
|
290 |
+
$val = $new_values;
|
291 |
+
}
|
292 |
+
break;
|
293 |
+
}
|
294 |
+
}
|
295 |
+
if ( $error )
|
296 |
+
add_settings_error( 'general', 'setting_not_int', $msg, 'error' );
|
297 |
+
$options[$opt] = $val;
|
298 |
+
}
|
299 |
+
}
|
300 |
+
$options = apply_filters( $this->get_hook( 'before_update_option' ), $options, $this );
|
301 |
+
}
|
302 |
+
return $options;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Initializes the plugin's configuration and localizable text variables.
|
307 |
+
*
|
308 |
+
* @return void
|
309 |
+
*/
|
310 |
+
function load_config() {
|
311 |
+
die( 'Function load_config() must be overridden in sub-class.' );
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Verify that the necessary configuration files were set in the inheriting class.
|
316 |
+
*
|
317 |
+
* @return void
|
318 |
+
*/
|
319 |
+
function verify_config() {
|
320 |
+
// Ensure required configuration options have been configured via the sub-class. Die if any aren't.
|
321 |
+
foreach ( $this->required_config as $config ) {
|
322 |
+
if ( empty( $this->$config ) )
|
323 |
+
die( "The plugin configuration option '$config' must be supplied." );
|
324 |
+
}
|
325 |
+
// Set/change configuration options based on sub-class changes.
|
326 |
+
if ( empty( $this->config ) )
|
327 |
+
$this->show_admin = false;
|
328 |
+
else {
|
329 |
+
// Initialize any option attributes that weren't specified by the plugin
|
330 |
+
foreach ( $this->get_option_names( true ) as $opt ) {
|
331 |
+
foreach ( array( 'datatype', 'default', 'help', 'input', 'input_attributes', 'label', 'no_wrap', 'options', 'output' ) as $attrib ) {
|
332 |
+
if ( !isset( $this->config[$opt][$attrib] ) )
|
333 |
+
$this->config[$opt][$attrib] = '';
|
334 |
+
}
|
335 |
+
$this->config[$opt]['allow_html'] = false;
|
336 |
+
$this->config[$opt]['class'] = array();
|
337 |
+
}
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Loads the localization textdomain for the plugin.
|
343 |
+
*
|
344 |
+
* @return void
|
345 |
+
*/
|
346 |
+
function load_textdomain() {
|
347 |
+
$subdir = empty( $this->textdomain_subdir ) ? '' : '/'.$this->textdomain_subdir;
|
348 |
+
load_plugin_textdomain( $this->textdomain, false, basename( dirname( $this->plugin_file ) ) . $subdir );
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Registers filters.
|
353 |
+
* NOTE: This occurs during the 'init' filter, so you can't use this to hook anything that happens earlier
|
354 |
+
*
|
355 |
+
* @return void
|
356 |
+
*/
|
357 |
+
function register_filters() {
|
358 |
+
// This should be overridden in order to define filters.
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Outputs simple contextual help text, comprising solely of a thickboxed link to the plugin's hosted readme.txt file.
|
363 |
+
*
|
364 |
+
* NOTE: If overriding this in a sub-class, before sure to include the
|
365 |
+
* check at the beginning of the function to ensure it shows up on its
|
366 |
+
* own settings admin page.
|
367 |
+
*
|
368 |
+
* @param string $contextual_help The default contextual help
|
369 |
+
* @param int $screen_id The screen ID
|
370 |
+
* @param object $screen The screen object (only supplied in WP 3.0)
|
371 |
+
* @return void (Text is echoed)
|
372 |
+
*/
|
373 |
+
function contextual_help( $contextual_help, $screen_id, $screen = null ) {
|
374 |
+
if ( $screen_id != $this->options_page )
|
375 |
+
return $contextual_help;
|
376 |
+
|
377 |
+
$help_url = admin_url( "plugin-install.php?tab=plugin-information&plugin={$this->id_base}&TB_iframe=true&width=640&height=656" );
|
378 |
+
|
379 |
+
echo '<p class="more-help">';
|
380 |
+
echo '<a title="' . esc_attr( sprintf( __( 'More information about %1$s %2$s', $this->textdomain ), $this->name, $this->version ) ) .
|
381 |
+
'" class="thickbox" href="' . $help_url . '">' . __( 'Click for more help on this plugin', $this->textdomain ) . '</a>' .
|
382 |
+
__( ' (especially check out the "Other Notes" tab, if present)', $this->textdomain );
|
383 |
+
echo ".</p>\n";
|
384 |
+
return;
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Outputs CSS into admin head of the plugin's settings page
|
389 |
+
*
|
390 |
+
* @return void
|
391 |
+
*/
|
392 |
+
function add_c2c_admin_css() {
|
393 |
+
global $c2c_plugin_max_css_version, $c2c_plugin_css_was_output;
|
394 |
+
if ( ( $c2c_plugin_max_css_version != $this->plugin_css_version ) || ( isset( $c2c_plugin_css_was_output ) && $c2c_plugin_css_was_output ) )
|
395 |
+
return;
|
396 |
+
$c2c_plugin_css_was_output = true;
|
397 |
+
$logo = plugins_url( 'c2c_minilogo.png', $this->plugin_file );
|
398 |
+
/**
|
399 |
+
* Remember to increment the plugin_css_version variable if changing the CSS
|
400 |
+
*/
|
401 |
+
echo <<<CSS
|
402 |
+
<style type="text/css">
|
403 |
+
.long-text {width:95% !important;}
|
404 |
+
#c2c {
|
405 |
+
text-align:center;
|
406 |
+
color:#888;
|
407 |
+
background-color:#ffffef;
|
408 |
+
padding:5px 0 0;
|
409 |
+
margin-top:12px;
|
410 |
+
border-style:solid;
|
411 |
+
border-color:#dadada;
|
412 |
+
border-width:1px 0;
|
413 |
+
}
|
414 |
+
#c2c div {
|
415 |
+
margin:0 auto;
|
416 |
+
padding:5px 40px 0 0;
|
417 |
+
width:45%;
|
418 |
+
min-height:40px;
|
419 |
+
background:url('$logo') no-repeat top right;
|
420 |
+
}
|
421 |
+
#c2c span {
|
422 |
+
display:block;
|
423 |
+
font-size:x-small;
|
424 |
+
}
|
425 |
+
.form-table {margin-bottom:20px;}
|
426 |
+
.c2c-plugin-list {margin-left:2em;}
|
427 |
+
.c2c-plugin-list li {list-style:disc outside;}
|
428 |
+
.wrap {margin-bottom:30px !important;}
|
429 |
+
.c2c-form input[type="checkbox"] {width:1.5em;}
|
430 |
+
.c2c-form .hr, .c2c-hr {border-bottom:1px solid #ccc;padding:0 2px;margin-bottom:6px;}
|
431 |
+
.c2c-input-help {color:#777;font-size:x-small;}
|
432 |
+
.c2c-fieldset {border:1px solid #ccc; padding:2px 8px;}
|
433 |
+
.c2c-textarea, .c2c-inline_textarea {width:95%;font-family:"Courier New", Courier, mono;}
|
434 |
+
.c2c-nowrap {
|
435 |
+
white-space:nowrap;overflow:scroll;overflow-y:hidden;overflow-x:scroll;overflow:-moz-scrollbars-horizontal
|
436 |
+
}
|
437 |
+
.see-help {font-size:x-small;font-style:italic;}
|
438 |
+
.more-help {display:block;margin-top:8px;}
|
439 |
+
</style>
|
440 |
+
|
441 |
+
CSS;
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Registers the admin options page and the Settings link.
|
446 |
+
*
|
447 |
+
* @return void
|
448 |
+
*/
|
449 |
+
function admin_menu() {
|
450 |
+
add_filter( 'plugin_action_links_' . $this->plugin_basename, array( &$this, 'plugin_action_links' ) );
|
451 |
+
switch ( $this->settings_page ) {
|
452 |
+
case 'options-general' :
|
453 |
+
$func_root = 'options';
|
454 |
+
break;
|
455 |
+
case 'themes' :
|
456 |
+
$func_root = 'theme';
|
457 |
+
break;
|
458 |
+
default :
|
459 |
+
$func_root = $this->settings_page;
|
460 |
+
}
|
461 |
+
$menu_func = 'add_' . $func_root . '_page';
|
462 |
+
if ( function_exists( $menu_func ) )
|
463 |
+
$this->options_page = call_user_func( $menu_func, $this->name, $this->menu_name, 'manage_options', $this->plugin_basename, array( &$this, 'options_page' ) );
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* Adds a 'Settings' link to the plugin action links.
|
468 |
+
*
|
469 |
+
* @param int $limit The default limit value for the current posts query.
|
470 |
+
* @return array Links associated with a plugin on the admin Plugins page
|
471 |
+
*/
|
472 |
+
function plugin_action_links( $action_links ) {
|
473 |
+
$settings_link = '<a href="' . $this->settings_page . '.php?page='.$this->plugin_basename.'">' . __( 'Settings', $this->textdomain ) . '</a>';
|
474 |
+
array_unshift( $action_links, $settings_link );
|
475 |
+
return $action_links;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* See if the setting is pertinent to this version of WP
|
480 |
+
*
|
481 |
+
* @since 013
|
482 |
+
*
|
483 |
+
* @param string $opt The option name
|
484 |
+
* @return bool If the option is valid for this version of WP
|
485 |
+
*/
|
486 |
+
function is_option_valid( $opt ) {
|
487 |
+
global $wp_version;
|
488 |
+
$valid = true;
|
489 |
+
$ver_operators = array( 'wpgt' => '>', 'wpgte' => '>=', 'wplt' => '<', 'wplte' => '<=' );
|
490 |
+
foreach ( $ver_operators as $ver_check => $ver_op ) {
|
491 |
+
if ( isset( $this->config[$opt][$ver_check] )
|
492 |
+
&& !empty( $this->config[$opt][$ver_check] )
|
493 |
+
&& !version_compare( $wp_version, $this->config[$opt][$ver_check], $ver_op ) ) {
|
494 |
+
$valid = false;
|
495 |
+
break;
|
496 |
+
}
|
497 |
+
}
|
498 |
+
return $valid;
|
499 |
+
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Returns the list of option names.
|
503 |
+
*
|
504 |
+
* @param bool $include_non_options (optional) Should non-options be included? Default is false.
|
505 |
+
* @return array Array of option names.
|
506 |
+
*/
|
507 |
+
function get_option_names( $include_non_options = false ) {
|
508 |
+
if ( !$include_non_options && !empty( $this->option_names ) )
|
509 |
+
return $this->option_names;
|
510 |
+
if ( $include_non_options )
|
511 |
+
return array_keys( $this->config );
|
512 |
+
$this->option_names = array();
|
513 |
+
foreach ( array_keys( $this->config ) as $opt ) {
|
514 |
+
if ( isset( $this->config[$opt]['input'] ) && $this->config[$opt]['input'] != '' && $this->config[$opt]['input'] != 'none' && $this->is_option_valid( $opt ) )
|
515 |
+
$this->option_names[] = $opt;
|
516 |
+
}
|
517 |
+
return $this->option_names;
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Returns either the buffered array of all options for the plugin, or
|
522 |
+
* obtains the options and buffers the value.
|
523 |
+
*
|
524 |
+
* @param bool $with_current_values (optional) Should the currently saved values be returned? If false, then the plugin's defaults are returned. Default is true.
|
525 |
+
* @return array The options array for the plugin (which is also stored in $this->options if !$with_options).
|
526 |
+
*/
|
527 |
+
function get_options( $with_current_values = true ) {
|
528 |
+
if ( $with_current_values && !empty( $this->options ) )
|
529 |
+
return $this->options;
|
530 |
+
// Derive options from the config
|
531 |
+
$options = array();
|
532 |
+
$option_names = $this->get_option_names( !$with_current_values );
|
533 |
+
foreach ( $option_names as $opt )
|
534 |
+
$options[$opt] = $this->config[$opt]['default'];
|
535 |
+
if ( !$with_current_values )
|
536 |
+
return $options;
|
537 |
+
$this->options = wp_parse_args( get_option( $this->admin_options_name ), $options );
|
538 |
+
// Un-escape fields
|
539 |
+
foreach ( $option_names as $opt ) {
|
540 |
+
if ( $this->config[$opt]['allow_html'] == true ) {
|
541 |
+
if ( is_array( $this->options[$opt] ) ) {
|
542 |
+
foreach ( $this->options[$opt] as $key => $val ) {
|
543 |
+
$new_key = wp_specialchars_decode( $key, ENT_QUOTES );
|
544 |
+
$new_val = wp_specialchars_decode( $val, ENT_QUOTES );
|
545 |
+
$this->options[$opt][$new_key] = $new_val;
|
546 |
+
if ( $key != $new_key )
|
547 |
+
unset( $this->options[$opt][$key] );
|
548 |
+
}
|
549 |
+
} else {
|
550 |
+
$this->options[$opt] = wp_specialchars_decode( $this->options[$opt], ENT_QUOTES );
|
551 |
+
}
|
552 |
+
}
|
553 |
+
}
|
554 |
+
return apply_filters( $this->get_hook( 'options' ), $this->options );
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Gets the name to use for a form's <input type="hidden" name="XXX" value="1" />
|
559 |
+
*
|
560 |
+
* @param string $prefix A prefix string, unique to the form
|
561 |
+
* @return string The name
|
562 |
+
*/
|
563 |
+
function get_form_submit_name( $prefix ) {
|
564 |
+
return $prefix . '_' . $this->u_id_base;
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* Returns the URL for a plugin's form to use for its action attribute
|
569 |
+
*
|
570 |
+
* @return string The action URL
|
571 |
+
*/
|
572 |
+
function form_action_url() {
|
573 |
+
return $_SERVER['PHP_SELF'] . '?page=' . $this->plugin_basename;
|
574 |
+
}
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Checks if the plugin's settings page has been submitted.
|
578 |
+
*
|
579 |
+
* @param string $prefix The prefix for the form's unique submit hidden input field
|
580 |
+
* @return bool True if the plugin's settings have been submitted for saving, else false.
|
581 |
+
*/
|
582 |
+
function is_submitting_form( $prefix ) {
|
583 |
+
return ( isset( $_POST['option_page'] ) && ( $_POST['option_page'] == $this->admin_options_name ) );
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Checks if the current page is the plugin's settings page.
|
588 |
+
*
|
589 |
+
* @return bool True if on the plugin's settings page, else false.
|
590 |
+
*/
|
591 |
+
function is_plugin_admin_page() {
|
592 |
+
global $pagenow;
|
593 |
+
return ( basename( $pagenow, '.php' ) == $this->settings_page && isset( $_REQUEST['page'] ) && $_REQUEST['page'] == $this->plugin_basename );
|
594 |
+
}
|
595 |
+
|
596 |
+
/**
|
597 |
+
* Outputs the markup for an option's form field (and surrounding markup)
|
598 |
+
*
|
599 |
+
* @param string $opt The name/key of the option.
|
600 |
+
* @return void
|
601 |
+
*/
|
602 |
+
function display_option( $opt ) {
|
603 |
+
do_action( $this->get_hook( 'pre_display_option' ), $opt );
|
604 |
+
|
605 |
+
$options = $this->get_options();
|
606 |
+
|
607 |
+
foreach ( array( 'datatype', 'input' ) as $attrib )
|
608 |
+
$$attrib = isset( $this->config[$opt][$attrib] ) ? $this->config[$opt][$attrib] : '';
|
609 |
+
|
610 |
+
if ( $input == '' || $input == 'none' )
|
611 |
+
return;
|
612 |
+
elseif ( $input == 'custom' ) {
|
613 |
+
do_action( $this->get_hook( 'custom_display_option' ), $opt );
|
614 |
+
return;
|
615 |
+
}
|
616 |
+
$value = isset( $options[$opt] ) ? $options[$opt] : '';
|
617 |
+
$popt = $this->admin_options_name . "[$opt]";
|
618 |
+
if ( $input == 'multiselect' ) {
|
619 |
+
// Do nothing since it needs the values as an array
|
620 |
+
$popt .= '[]';
|
621 |
+
} elseif ( $datatype == 'array' ) {
|
622 |
+
if ( !is_array( $value ) )
|
623 |
+
$value = '';
|
624 |
+
else {
|
625 |
+
if ( $input == 'textarea' || $input == 'inline_textarea' )
|
626 |
+
$value = implode( "\n", $value );
|
627 |
+
else
|
628 |
+
$value = implode( ', ', $value );
|
629 |
+
}
|
630 |
+
} elseif ( $datatype == 'hash' && $input != 'select' ) {
|
631 |
+
if ( !is_array( $value ) )
|
632 |
+
$value = '';
|
633 |
+
else {
|
634 |
+
$new_value = '';
|
635 |
+
foreach ( $value AS $shortcut => $replacement )
|
636 |
+
$new_value .= "$shortcut => $replacement\n";
|
637 |
+
$value = $new_value;
|
638 |
+
}
|
639 |
+
}
|
640 |
+
$attributes = $this->config[$opt]['input_attributes'];
|
641 |
+
$this->config[$opt]['class'][] = 'c2c-' . $input;
|
642 |
+
if ( ( 'textarea' == $input || 'inline_textarea' == $input ) && $this->config[$opt]['no_wrap'] ) {
|
643 |
+
$this->config[$opt]['class'][] = 'c2c-nowrap';
|
644 |
+
$attributes .= ' wrap="off"'; // Unfortunately CSS is not enough
|
645 |
+
}
|
646 |
+
elseif ( in_array( $input, array( 'text', 'long_text', 'short_text' ) ) ) {
|
647 |
+
$this->config[$opt]['class'][] = ( ( $input == 'short_text' ) ? 'small-text' : 'regular-text' );
|
648 |
+
if ( $input == 'long_text' )
|
649 |
+
$this->config[$opt]['class'][] = ' long-text';
|
650 |
+
}
|
651 |
+
$class = implode( ' ', $this->config[$opt]['class'] );
|
652 |
+
$attribs = "name='$popt' id='$opt' class='$class' $attributes";
|
653 |
+
if ( $input == '' ) {
|
654 |
+
// Change of implementation prevents this from being possible (since this function only gets called for registered settings)
|
655 |
+
// if ( !empty( $this->config[$opt]['output'] ) )
|
656 |
+
// echo $this->config[$opt]['output'] . "\n";
|
657 |
+
// else
|
658 |
+
// echo '<div class="hr"> </div>' . "\n";
|
659 |
+
} elseif ( $input == 'textarea' || $input == 'inline_textarea' ) {
|
660 |
+
if ( $input == 'textarea' )
|
661 |
+
echo "</td><tr><td colspan='2'>";
|
662 |
+
echo "<textarea $attribs>$value</textarea>\n";
|
663 |
+
} elseif ( $input == 'select' ) {
|
664 |
+
echo "<select $attribs>";
|
665 |
+
if ( $this->config[$opt]['datatype'] == 'hash' ) {
|
666 |
+
foreach ( (array) $this->config[$opt]['options'] as $sopt => $sval )
|
667 |
+
echo "<option value='$sopt' " . selected( $value, $sopt, false ) . ">$sval</option>\n";
|
668 |
+
} else {
|
669 |
+
foreach ( (array) $this->config[$opt]['options'] as $sopt )
|
670 |
+
echo "<option value='$sopt' " . selected( $value, $sopt, false ) . ">$sopt</option>\n";
|
671 |
+
}
|
672 |
+
echo "</select>";
|
673 |
+
} elseif ( $input == 'multiselect' ) {
|
674 |
+
echo '<fieldset class="c2c-fieldset">' . "\n";
|
675 |
+
foreach ( (array) $this->config[$opt]['options'] as $sopt )
|
676 |
+
echo "<input type='checkbox' $attribs value='$sopt' " . checked( in_array( $sopt, $value ), true, false ) . ">$sopt</input><br />\n";
|
677 |
+
echo '</fieldset>';
|
678 |
+
} elseif ( $input == 'checkbox' ) {
|
679 |
+
echo "<input type='$input' $attribs value='1' " . checked( $value, 1, false ) . " />\n";
|
680 |
+
} else {
|
681 |
+
echo "<input type='text' $attribs value='" . esc_attr( $value ) . "' />\n";
|
682 |
+
}
|
683 |
+
if ( $help = apply_filters( $this->get_hook( 'option_help'), $this->config[$opt]['help'], $opt ) )
|
684 |
+
echo "<br /><span class='c2c-input-help'>$help</span>\n";
|
685 |
+
|
686 |
+
do_action( $this->get_hook( 'post_display_option' ), $opt );
|
687 |
+
}
|
688 |
+
|
689 |
+
/**
|
690 |
+
* Outputs the descriptive text (and h2 heading) for the options page.
|
691 |
+
*
|
692 |
+
* Intended to be overridden by sub-class.
|
693 |
+
*
|
694 |
+
* @param string $localized_heading_text (optional) Localized page heading text.
|
695 |
+
* @return void
|
696 |
+
*/
|
697 |
+
function options_page_description( $localized_heading_text = '' ) {
|
698 |
+
if ( empty( $localized_heading_text ) )
|
699 |
+
$localized_heading_text = $this->name;
|
700 |
+
if ( $localized_heading_text )
|
701 |
+
echo '<h2>' . $localized_heading_text . "</h2>\n";
|
702 |
+
if ( !$this->disable_contextual_help )
|
703 |
+
echo '<p class="see-help">' . __( 'See the "Help" link to the top-right of the page for more help.', $this->textdomain ) . "</p>\n";
|
704 |
+
}
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Outputs the options page for the plugin, and saves user updates to the
|
708 |
+
* options.
|
709 |
+
*
|
710 |
+
* @return void
|
711 |
+
*/
|
712 |
+
function options_page() {
|
713 |
+
$options = $this->get_options();
|
714 |
+
|
715 |
+
if ( $this->saved_settings )
|
716 |
+
echo "<div id='message' class='updated fade'><p><strong>" . $this->saved_settings_msg . '</strong></p></div>';
|
717 |
+
|
718 |
+
$logo = plugins_url( basename( $_GET['page'], '.php' ) . '/c2c_minilogo.png' );
|
719 |
+
|
720 |
+
echo "<div class='wrap'>\n";
|
721 |
+
echo "<div class='icon32' style='width:44px;'><img src='$logo' alt='" . esc_attr__( 'A plugin by coffee2code', $this->textdomain ) . "' /><br /></div>\n";
|
722 |
+
|
723 |
+
$this->options_page_description();
|
724 |
+
|
725 |
+
do_action( $this->get_hook( 'before_settings_form' ), $this );
|
726 |
+
|
727 |
+
echo "<form action='options.php' method='post' class='c2c-form'>\n";
|
728 |
+
|
729 |
+
settings_fields( $this->admin_options_name );
|
730 |
+
do_settings_sections( $this->plugin_file );
|
731 |
+
|
732 |
+
echo '<input type="submit" name="Submit" class="button-primary" value="' . esc_attr__( 'Save Changes', $this->textdomain ) . '" />' . "\n";
|
733 |
+
echo '<input type="submit" name="Reset" class="button" value="' . esc_attr__( 'Reset Settings', $this->textdomain ) . '" />' . "\n";
|
734 |
+
echo '</form>' . "\n";
|
735 |
+
|
736 |
+
do_action( $this->get_hook( 'after_settings_form' ), $this );
|
737 |
+
|
738 |
+
echo '<div id="c2c" class="wrap"><div>' . "\n";
|
739 |
+
$c2c = '<a href="http://coffee2code.com" title="coffee2code.com">' . __( 'Scott Reilly, aka coffee2code', $this->textdomain ) . '</a>';
|
740 |
+
echo sprintf( __( 'This plugin brought to you by %s.', $this->textdomain ), $c2c );
|
741 |
+
echo '<span><a href="http://coffee2code.com/donate" title="' . esc_attr__( 'Please consider a donation', $this->textdomain ) . '">' .
|
742 |
+
__( 'Did you find this plugin useful?', $this->textdomain ) . '</a></span>';
|
743 |
+
echo '</div></div>' . "\n";
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Returns the full plugin-specific name for a hook.
|
748 |
+
*
|
749 |
+
* @param string $hook The name of a hook, to be made plugin-specific.
|
750 |
+
* @return string The plugin-specific version of the hook name.
|
751 |
+
*/
|
752 |
+
function get_hook( $hook ) {
|
753 |
+
return $this->hook_prefix . '_' . $hook;
|
754 |
+
}
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Returns the URL for the plugin's readme.txt file on wordpress.org/extend/plugins
|
758 |
+
*
|
759 |
+
* @since 005
|
760 |
+
*
|
761 |
+
* @return string The URL
|
762 |
+
*/
|
763 |
+
function readme_url() {
|
764 |
+
return 'http://wordpress.org/extend/plugins/' . $this->id_base . '/tags/' . $this->version . '/readme.txt';
|
765 |
+
}
|
766 |
+
} // end class
|
767 |
+
|
768 |
+
endif; // end if !class_exists()
|
769 |
+
|
770 |
+
?>
|
configure-smtp.php
CHANGED
@@ -1,57 +1,32 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
/*
|
3 |
Plugin Name: Configure SMTP
|
4 |
-
Version:
|
5 |
-
Plugin URI: http://coffee2code.com/wp-plugins/configure-smtp
|
6 |
Author: Scott Reilly
|
7 |
Author URI: http://coffee2code.com
|
|
|
8 |
Description: Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
* SMTP host name
|
16 |
-
* SMTP port number
|
17 |
-
* If SMTPAuth (authentication) should be used.
|
18 |
-
* SMTP username
|
19 |
-
* SMTP password
|
20 |
-
* If the SMTP connection needs to occur over ssl or tls
|
21 |
-
|
22 |
-
In addition, you can instead indicate that you wish to use GMail to handle outgoing e-mail, in which case the above
|
23 |
-
settings are automatically configured to values appropriate for GMail, though you'll need to specify your GMail
|
24 |
-
e-mail (included the "@gmail.com") and password.
|
25 |
-
|
26 |
-
Regardless of whether SMTP is enabled or configured, the plugin provides you the ability to define the name and
|
27 |
-
email of the 'From:' field for all outgoing e-mails.
|
28 |
-
|
29 |
-
A simple test button is also available that allows you to send a test e-mail to yourself to check if sending
|
30 |
-
e-mail has been properly configured for your blog.
|
31 |
-
|
32 |
-
Compatible with WordPress 2.8+, 2.9+.
|
33 |
-
|
34 |
-
=>> Read the accompanying readme.txt file for more information. Also, visit the plugin's homepage
|
35 |
-
=>> for more information and the latest updates
|
36 |
-
|
37 |
-
Installation:
|
38 |
-
|
39 |
-
1. Download the file http://coffee2code.com/wp-plugins/configure-smtp.zip and unzip it into your
|
40 |
-
/wp-content/plugins/ directory (or install via the built-in WordPress plugin installer).
|
41 |
-
2. Activate the plugin through the 'Plugins' admin menu in WordPress.
|
42 |
-
3. Click the plugin's 'Settings' link next to its 'Deactivate' link (still on the Plugins page), or click on the
|
43 |
-
Settings -> SMTP link, to go to the plugin's admin settings page. Optionally customize the settings (to configure it
|
44 |
-
if the defaults aren't valid for your situation).
|
45 |
-
4. (optional) Use the built-in test to see if your blog can properly send out e-mails.
|
46 |
|
47 |
*/
|
48 |
|
49 |
/*
|
50 |
Copyright (c) 2004-2010 by Scott Reilly (aka coffee2code)
|
51 |
|
52 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
53 |
-
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
54 |
-
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
55 |
Software is furnished to do so, subject to the following conditions:
|
56 |
|
57 |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
@@ -62,85 +37,112 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRA
|
|
62 |
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
63 |
*/
|
64 |
|
65 |
-
if ( !class_exists('
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
class ConfigureSMTP {
|
68 |
-
var $admin_options_name = 'c2c_configure_smtp';
|
69 |
-
var $nonce_field = 'update-configure_smtp';
|
70 |
-
var $textdomain = 'configure-smtp';
|
71 |
-
var $show_admin = true; // Change this to false if you don't want the plugin's admin page shown.
|
72 |
-
var $plugin_name = '';
|
73 |
-
var $short_name = '';
|
74 |
-
var $plugin_basename = '';
|
75 |
-
var $config = array();
|
76 |
var $gmail_config = array(
|
77 |
'host' => 'smtp.gmail.com',
|
78 |
'port' => '465',
|
79 |
'smtp_auth' => true,
|
80 |
'smtp_secure' => 'ssl'
|
81 |
);
|
82 |
-
var $options = array(); // Don't use this directly
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
$this->config = array(
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
'
|
95 |
-
'label' => __('
|
96 |
-
'help' => __('
|
97 |
-
|
98 |
-
|
99 |
-
'
|
100 |
-
|
101 |
-
|
102 |
-
'
|
103 |
-
'help' => __('
|
104 |
-
'
|
105 |
-
'label' => __('
|
106 |
-
'
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
-
|
111 |
-
|
112 |
-
'
|
113 |
-
|
114 |
-
|
115 |
-
'
|
116 |
-
|
117 |
-
'
|
118 |
-
'label' => __('
|
119 |
-
'help' => __('Sets
|
120 |
-
'
|
121 |
-
'label' => __('Sender
|
122 |
-
'help' => __('Sets the From
|
123 |
-
'from_name' => array('input' => 'text', 'default' => '',
|
124 |
-
'label' => __('Sender name', $this->textdomain),
|
125 |
-
'help' => __('Sets the From name for all outgoing messages. Leave blank to use the WordPress default. This value will be used even if you don\'t enable SMTP.', $this->textdomain))
|
126 |
);
|
|
|
127 |
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
if ( 'options-general.php' == $pagenow )
|
130 |
-
add_action('
|
131 |
-
add_action('
|
132 |
-
add_action('phpmailer_init', array(&$this, 'phpmailer_init'));
|
133 |
-
add_action('wp_mail_from', array(&$this, 'wp_mail_from'));
|
134 |
-
add_action('wp_mail_from_name', array(&$this, 'wp_mail_from_name'));
|
|
|
|
|
135 |
}
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
142 |
function add_js() {
|
143 |
-
$alert = __('Be sure to specify your GMail email address (with the @gmail.com) as the SMTP username, and your GMail password as the SMTP password.', $this->textdomain);
|
144 |
echo <<<JS
|
145 |
<script type="text/javascript">
|
146 |
function configure_gmail() {
|
@@ -161,21 +163,83 @@ class ConfigureSMTP {
|
|
161 |
JS;
|
162 |
}
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
}
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
function phpmailer_init( $phpmailer ) {
|
178 |
$options = $this->get_options();
|
|
|
|
|
|
|
179 |
$phpmailer->IsSMTP();
|
180 |
$phpmailer->Host = $options['host'];
|
181 |
$phpmailer->Port = $options['port'] ? $options['port'] : 25;
|
@@ -188,9 +252,14 @@ JS;
|
|
188 |
$phpmailer->SMTPSecure = $options['smtp_secure'];
|
189 |
if ( $options['wordwrap'] > 0 )
|
190 |
$phpmailer->WordWrap = $options['wordwrap'];
|
191 |
-
return $phpmailer;
|
192 |
}
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
function wp_mail_from( $from ) {
|
195 |
$options = $this->get_options();
|
196 |
if ( $options['from_email'] )
|
@@ -198,211 +267,23 @@ JS;
|
|
198 |
return $from;
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
function wp_mail_from_name( $from_name ) {
|
202 |
$options = $this->get_options();
|
203 |
if ( $options['from_name'] )
|
204 |
-
$from_name =
|
205 |
return $from_name;
|
206 |
}
|
207 |
|
208 |
-
|
209 |
-
if ( !empty($this->options) ) return $this->options;
|
210 |
-
// Derive options from the config
|
211 |
-
$options = array();
|
212 |
-
foreach (array_keys($this->config) as $opt) {
|
213 |
-
$options[$opt] = $this->config[$opt]['default'];
|
214 |
-
}
|
215 |
-
$existing_options = get_option($this->admin_options_name);
|
216 |
-
if ( !empty($existing_options) ) {
|
217 |
-
foreach ($existing_options as $key => $value)
|
218 |
-
$options[$key] = $value;
|
219 |
-
}
|
220 |
-
$this->options = $options;
|
221 |
-
return $options;
|
222 |
-
}
|
223 |
|
224 |
-
|
225 |
-
$options = $this->get_options();
|
226 |
-
// See if user has submitted form
|
227 |
-
if ( isset($_POST['submitted']) ) {
|
228 |
-
check_admin_referer($this->nonce_field);
|
229 |
-
|
230 |
-
foreach (array_keys($options) AS $opt) {
|
231 |
-
$options[$opt] = htmlspecialchars(stripslashes($_POST[$opt]));
|
232 |
-
$input = $this->config[$opt]['input'];
|
233 |
-
if ( ($input == 'checkbox') && !$options[$opt] )
|
234 |
-
$options[$opt] = 0;
|
235 |
-
if ( $this->config[$opt]['datatype'] == 'array' ) {
|
236 |
-
if ( $input == 'text' )
|
237 |
-
$options[$opt] = explode(',', str_replace(array(', ', ' ', ','), ',', $options[$opt]));
|
238 |
-
else
|
239 |
-
$options[$opt] = array_map('trim', explode("\n", trim($options[$opt])));
|
240 |
-
}
|
241 |
-
elseif ( $this->config[$opt]['datatype'] == 'hash' ) {
|
242 |
-
if ( !empty($options[$opt]) ) {
|
243 |
-
$new_values = array();
|
244 |
-
foreach (explode("\n", $options[$opt]) AS $line) {
|
245 |
-
list($shortcut, $text) = array_map('trim', explode("=>", $line, 2));
|
246 |
-
if ( !empty($shortcut) ) $new_values[str_replace('\\', '', $shortcut)] = str_replace('\\', '', $text);
|
247 |
-
}
|
248 |
-
$options[$opt] = $new_values;
|
249 |
-
}
|
250 |
-
}
|
251 |
-
}
|
252 |
-
// If GMail is to be used, those settings take precendence
|
253 |
-
if ( $options['use_gmail'] )
|
254 |
-
$options = wp_parse_args($this->gmail_config, $options);
|
255 |
-
|
256 |
-
// Remember to put all the other options into the array or they'll get lost!
|
257 |
-
update_option($this->admin_options_name, $options);
|
258 |
-
$this->options = $options;
|
259 |
-
echo "<div id='message' class='updated fade'><p><strong>" . __('Settings saved', $this->textdomain) . '</strong></p></div>';
|
260 |
-
}
|
261 |
-
elseif ( isset($_POST['submit_test_email']) ) {
|
262 |
-
check_admin_referer($this->nonce_field);
|
263 |
-
$user = wp_get_current_user();
|
264 |
-
$email = $user->user_email;
|
265 |
-
$timestamp = current_time('mysql');
|
266 |
-
|
267 |
-
$message = sprintf(__('Hi, this is the %s plugin e-mailing you a test message from your WordPress blog.', $this->textdomain), $this->plugin_name);
|
268 |
-
$message .= "\n\n";
|
269 |
-
$message .= sprintf(__('This message was sent with this time-stamp: %s', $this->textdomain), $timestamp);
|
270 |
-
$message .= "\n\n";
|
271 |
-
$message .= __('Congratulations! Your blog is properly configured to send e-mail.', $this->textdomain);
|
272 |
-
wp_mail($email, __('Test message from your WordPress blog', $this->textdomain), $message);
|
273 |
-
echo '<div class="updated"><p>' . __('Test e-mail sent.', $this->textdomain) . '</p>';
|
274 |
-
echo '<p>' . sprintf(__('The body of the e-mail includes this time-stamp: %s.', $this->textdomain), $timestamp) . '</p></div>';
|
275 |
-
}
|
276 |
-
|
277 |
-
$action_url = $_SERVER['PHP_SELF'] . '?page=' . $this->plugin_basename;
|
278 |
-
$logo = plugins_url(basename($_GET['page'], '.php') . '/c2c_minilogo.png');
|
279 |
-
|
280 |
-
echo "<div class='wrap'><div class='icon32' style='width:44px;'><img src='$logo' alt='" . esc_attr__('A plugin by coffee2code', $this->textdomain) . "' /><br /></div>";
|
281 |
-
echo '<h2>' . __('Configure SMTP Settings', $this->textdomain) . '</h2>';
|
282 |
-
$str = '<a href="#test">' . __('test', $this->textdomain) . '</a>';
|
283 |
-
echo '<p>' . sprintf(__('After you\'ve configured your SMTP settings, use the %s to send a test message to yourself.', $this->textdomain), $str) . '</p>';
|
284 |
-
echo "<form name='configure_smtp' action='$action_url' method='post'>";
|
285 |
-
wp_nonce_field($this->nonce_field);
|
286 |
-
echo '<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform form-table">';
|
287 |
-
foreach (array_keys($options) as $opt) {
|
288 |
-
$input = $this->config[$opt]['input'];
|
289 |
-
if ($input == 'none') continue;
|
290 |
-
$label = $this->config[$opt]['label'];
|
291 |
-
$value = $options[$opt];
|
292 |
-
if ($input == 'checkbox') {
|
293 |
-
$checked = ($value == 1) ? 'checked=checked ' : '';
|
294 |
-
$value = 1;
|
295 |
-
} else {
|
296 |
-
$checked = '';
|
297 |
-
};
|
298 |
-
if ($this->config[$opt]['datatype'] == 'array') {
|
299 |
-
if ($input == 'textarea' || $input == 'inline_textarea')
|
300 |
-
$value = implode("\n", $value);
|
301 |
-
else
|
302 |
-
$value = implode(', ', $value);
|
303 |
-
} elseif ($this->config[$opt]['datatype'] == 'hash') {
|
304 |
-
$new_value = '';
|
305 |
-
foreach ($value AS $shortcut => $replacement) {
|
306 |
-
$new_value .= "$shortcut => $replacement\n";
|
307 |
-
}
|
308 |
-
$value = $new_value;
|
309 |
-
}
|
310 |
-
echo "<tr valign='top'>";
|
311 |
-
if ($input == 'textarea') {
|
312 |
-
echo "<td colspan='2'>";
|
313 |
-
if ($label) echo "<strong>$label</strong><br />";
|
314 |
-
echo "<textarea name='$opt' id='$opt' {$this->config[$opt]['input_attributes']}>" . $value . '</textarea>';
|
315 |
-
} else {
|
316 |
-
echo "<th scope='row'>$label</th><td>";
|
317 |
-
if ($input == "inline_textarea")
|
318 |
-
echo "<textarea name='$opt' id='$opt' {$this->config[$opt]['input_attributes']}>" . $value . '</textarea>';
|
319 |
-
elseif ($input == 'select') {
|
320 |
-
echo "<select name='$opt' id='$opt'>";
|
321 |
-
foreach ($this->config[$opt]['options'] as $sopt) {
|
322 |
-
$selected = $value == $sopt ? " selected='selected'" : '';
|
323 |
-
echo "<option value='$sopt'$selected>$sopt</option>";
|
324 |
-
}
|
325 |
-
echo "</select>";
|
326 |
-
} else {
|
327 |
-
$tclass = ($input == 'short_text') ? 'small-text' : 'regular-text';
|
328 |
-
if ($input == 'short_text') $input = 'text';
|
329 |
-
echo "<input name='$opt' type='$input' id='$opt' value='$value' class='$tclass' $checked {$this->config[$opt]['input_attributes']} />";
|
330 |
-
}
|
331 |
-
}
|
332 |
-
if ($this->config[$opt]['help']) {
|
333 |
-
echo "<br /><span style='color:#777; font-size:x-small;'>";
|
334 |
-
echo $this->config[$opt]['help'];
|
335 |
-
echo "</span>";
|
336 |
-
}
|
337 |
-
echo "</td></tr>";
|
338 |
-
}
|
339 |
-
$txt = __('Save Changes', $this->textdomain);
|
340 |
-
echo <<<END
|
341 |
-
</table>
|
342 |
-
<input type="hidden" name="submitted" value="1" />
|
343 |
-
<div class="submit"><input type="submit" name="Submit" class="button-primary" value="{$txt}" /></div>
|
344 |
-
</form>
|
345 |
-
</div>
|
346 |
-
END;
|
347 |
-
echo <<<END
|
348 |
-
<style type="text/css">
|
349 |
-
#c2c {
|
350 |
-
text-align:center;
|
351 |
-
color:#888;
|
352 |
-
background-color:#ffffef;
|
353 |
-
padding:5px 0 0;
|
354 |
-
margin-top:12px;
|
355 |
-
border-style:solid;
|
356 |
-
border-color:#dadada;
|
357 |
-
border-width:1px 0;
|
358 |
-
}
|
359 |
-
#c2c div {
|
360 |
-
margin:0 auto;
|
361 |
-
padding:5px 40px 0 0;
|
362 |
-
width:45%;
|
363 |
-
min-height:40px;
|
364 |
-
background:url('$logo') no-repeat top right;
|
365 |
-
}
|
366 |
-
#c2c span {
|
367 |
-
display:block;
|
368 |
-
font-size:x-small;
|
369 |
-
}
|
370 |
-
</style>
|
371 |
-
<div id='c2c' class='wrap'>
|
372 |
-
<div>
|
373 |
-
END;
|
374 |
-
$c2c = '<a href="http://coffee2code.com" title="coffee2code.com">' . __('Scott Reilly, aka coffee2code', $this->textdomain) . '</a>';
|
375 |
-
echo sprintf(__('This plugin brought to you by %s.', $this->textdomain), $c2c);
|
376 |
-
echo '<span><a href="http://coffee2code.com/donate" title="' . esc_attr__('Please consider a donation', $this->textdomain) . '">' .
|
377 |
-
__('Did you find this plugin useful?', $this->textdomain) . '</a></span>';
|
378 |
-
echo '</div></div>';
|
379 |
-
|
380 |
-
$user = wp_get_current_user();
|
381 |
-
$email = $user->user_email;
|
382 |
-
echo '<div class="wrap"><h2><a name="test"></a>' . __('Send A Test', $this->textdomain) . "</h2>\n";
|
383 |
-
echo '<p>' . __('Click the button below to send a test email to yourself to see if things are working. Be sure to save any changes you made to the form above before sending the test e-mail. Bear in mind it may take a few minutes for the e-mail to wind its way through the internet.', $this->textdomain) . "</p>\n";
|
384 |
-
echo '<p>' . sprintf(__('This e-mail will be sent to your e-mail address, %s.', $this->textdomain), $email) . "</p>\n";
|
385 |
-
echo "<form name='configure_smtp' action='$action_url' method='post'>\n";
|
386 |
-
wp_nonce_field($this->nonce_field);
|
387 |
-
echo '<input type="hidden" name="submit_test_email" value="1" />';
|
388 |
-
echo '<div class="submit"><input type="submit" name="Submit" value="' . esc_attr__('Send test e-mail', $this->textdomain) . '" /></div>';
|
389 |
-
echo '</form></div>';
|
390 |
-
}
|
391 |
-
|
392 |
-
} // end ConfigureSMTP
|
393 |
|
394 |
endif; // end if !class_exists()
|
395 |
|
396 |
-
// This function was introduced in PHP5. Backcomp via http://php.net/manual/en/function.htmlspecialchars-decode.php
|
397 |
-
if ( !function_exists('htmlspecialchars_decode') ) {
|
398 |
-
function htmlspecialchars_decode( $string, $quote_style = ENT_COMPAT ) {
|
399 |
-
$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style));
|
400 |
-
if ( $quote_style === ENT_QUOTES ) { $translation['''] = '\''; }
|
401 |
-
return strtr($string, $translation);
|
402 |
-
}
|
403 |
-
}
|
404 |
-
|
405 |
-
if ( class_exists('ConfigureSMTP') )
|
406 |
-
new ConfigureSMTP();
|
407 |
-
|
408 |
?>
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* @package Configure_SMTP
|
4 |
+
* @author Scott Reilly
|
5 |
+
* @version 3.0
|
6 |
+
*/
|
7 |
/*
|
8 |
Plugin Name: Configure SMTP
|
9 |
+
Version: 3.0
|
10 |
+
Plugin URI: http://coffee2code.com/wp-plugins/configure-smtp/
|
11 |
Author: Scott Reilly
|
12 |
Author URI: http://coffee2code.com
|
13 |
+
Text Domain: configure-smtp
|
14 |
Description: Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
|
15 |
|
16 |
+
Compatible with WordPress 2.8+, 2.9+, 3.0+.
|
17 |
|
18 |
+
=>> Read the accompanying readme.txt file for instructions and documentation.
|
19 |
+
=>> Also, visit the plugin's homepage for additional information and updates.
|
20 |
+
=>> Or visit: http://wordpress.org/extend/plugins/configure-smtp/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
*/
|
23 |
|
24 |
/*
|
25 |
Copyright (c) 2004-2010 by Scott Reilly (aka coffee2code)
|
26 |
|
27 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
28 |
+
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
29 |
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
30 |
Software is furnished to do so, subject to the following conditions:
|
31 |
|
32 |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
37 |
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
38 |
*/
|
39 |
|
40 |
+
if ( !class_exists( 'c2c_ConfigureSMTP' ) ) :
|
41 |
+
|
42 |
+
require_once( 'c2c-plugin.php' );
|
43 |
+
|
44 |
+
class c2c_ConfigureSMTP extends C2C_Plugin_016 {
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
var $gmail_config = array(
|
47 |
'host' => 'smtp.gmail.com',
|
48 |
'port' => '465',
|
49 |
'smtp_auth' => true,
|
50 |
'smtp_secure' => 'ssl'
|
51 |
);
|
|
|
52 |
|
53 |
+
/**
|
54 |
+
* Constructor
|
55 |
+
*
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
function c2c_ConfigureSMTP() {
|
59 |
+
$this->C2C_Plugin_016( '3.0', 'configure-smtp', 'c2c', __FILE__, array() );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Initializes the plugin's configuration and localizable text variables.
|
64 |
+
*
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
function load_config() {
|
68 |
+
$this->name = __( 'Configure SMTP', $this->textdomain );
|
69 |
+
$this->menu_name = __( 'SMTP', $this->textdomain );
|
70 |
+
|
71 |
$this->config = array(
|
72 |
+
'use_gmail' => array( 'input' => 'checkbox', 'default' => false,
|
73 |
+
'label' => __( 'Send e-mail via GMail?', $this->textdomain ),
|
74 |
+
'help' => __( 'Clicking this will override many of the settings defined below. You will need to input your GMail username and password below.', $this->textdomain ),
|
75 |
+
'input_attributes' => 'onclick="return configure_gmail();"' ),
|
76 |
+
'host' => array( 'input' => 'text', 'default' => 'localhost', 'require' => true,
|
77 |
+
'label' => __( 'SMTP host', $this->textdomain ),
|
78 |
+
'help' => __( 'If "localhost" doesn\'t work for you, check with your host for the SMTP hostname.', $this->textdomain ) ),
|
79 |
+
'port' => array( 'input' => 'short_text', 'default' => 25, 'datatype' => 'int', 'required' => true,
|
80 |
+
'label' => __( 'SMTP port', $this->textdomain ),
|
81 |
+
'help' => __( 'This is generally 25.', $this->textdomain ) ),
|
82 |
+
'smtp_secure' => array( 'input' => 'select', 'default' => 'None',
|
83 |
+
'label' => __( 'Secure connection prefix', $this->textdomain ),
|
84 |
+
'options' => array( '', 'ssl', 'tls' ),
|
85 |
+
'help' => __( 'Sets connection prefix for secure connections (prefix method must be supported by your PHP install and your SMTP host)', $this->textdomain ) ),
|
86 |
+
'smtp_auth' => array( 'input' => 'checkbox', 'default' => false,
|
87 |
+
'label' => __( 'Use SMTPAuth?', $this->textdomain ),
|
88 |
+
'help' => __( 'If checked, you must provide the SMTP username and password below', $this->textdomain ) ),
|
89 |
+
'smtp_user' => array( 'input' => 'text', 'default' => '',
|
90 |
+
'label' => __( 'SMTP username', $this->textdomain ),
|
91 |
+
'help' => '' ),
|
92 |
+
'smtp_pass' => array( 'input' => 'password', 'default' => '',
|
93 |
+
'label' => __( 'SMTP password', $this->textdomain ),
|
94 |
+
'help' => '' ),
|
95 |
+
'wordwrap' => array( 'input' => 'short_text', 'default' => '',
|
96 |
+
'label' => __( 'Wordwrap length', $this->textdomain ),
|
97 |
+
'help' => __( 'Sets word wrapping on the body of the message to a given number of characters.', $this->textdomain ) ),
|
98 |
+
'hr' => array(),
|
99 |
+
'from_email' => array( 'input' => 'text', 'default' => '',
|
100 |
+
'label' => __( 'Sender e-mail', $this->textdomain ),
|
101 |
+
'help' => __( 'Sets the From e-mail address for all outgoing messages. Leave blank to use the WordPress default. This value will be used even if you don\'t enable SMTP. NOTE: This may not take effect depending on your mail server and settings, especially if using SMTPAuth (such as for GMail).', $this->textdomain ) ),
|
102 |
+
'from_name' => array( 'input' => 'text', 'default' => '',
|
103 |
+
'label' => __( 'Sender name', $this->textdomain ),
|
104 |
+
'help' => __( 'Sets the From name for all outgoing messages. Leave blank to use the WordPress default. This value will be used even if you don\'t enable SMTP.', $this->textdomain ) )
|
|
|
|
|
|
|
105 |
);
|
106 |
+
}
|
107 |
|
108 |
+
/**
|
109 |
+
* Override the plugin framework's register_filters() to actually actions against filters.
|
110 |
+
*
|
111 |
+
* @return void
|
112 |
+
*/
|
113 |
+
function register_filters() {
|
114 |
+
global $pagenow;
|
115 |
if ( 'options-general.php' == $pagenow )
|
116 |
+
add_action( 'admin_print_footer_scripts', array( &$this, 'add_js' ) );
|
117 |
+
add_action( 'admin_init', array( &$this, 'maybe_send_test' ) );
|
118 |
+
add_action( 'phpmailer_init', array( &$this, 'phpmailer_init' ) );
|
119 |
+
add_action( 'wp_mail_from', array( &$this, 'wp_mail_from' ) );
|
120 |
+
add_action( 'wp_mail_from_name', array( &$this, 'wp_mail_from_name' ) );
|
121 |
+
add_action( $this->get_hook( 'after_settings_form' ), array( &$this, 'send_test_form' ) );
|
122 |
+
add_filter( $this->get_hook( 'before_update_option' ), array( &$this, 'maybe_gmail_override' ) );
|
123 |
}
|
124 |
|
125 |
+
/**
|
126 |
+
* Outputs the text above the setting form
|
127 |
+
*
|
128 |
+
* @return void (Text will be echoed.)
|
129 |
+
*/
|
130 |
+
function options_page_description() {
|
131 |
+
$options = $this->get_options();
|
132 |
+
parent::options_page_description( __( 'Configure SMTP Settings', $this->textdomain ) );
|
133 |
+
$str = '<a href="#test">' . __( 'test', $this->textdomain ) . '</a>';
|
134 |
+
if ( empty( $options['host'] ) )
|
135 |
+
echo '<div class="error"><p>' . __( 'SMTP mailing is currently <strong>NOT ENABLED</strong> because no SMTP host has been specified.' ) . '</p></div>';
|
136 |
+
echo '<p>' . sprintf( __( 'After you have configured your SMTP settings, use the %s to send a test message to yourself.', $this->textdomain ), $str ) . '</p>';
|
137 |
}
|
138 |
|
139 |
+
/**
|
140 |
+
* Outputs JavaScript
|
141 |
+
*
|
142 |
+
* @return void (Text is echoed.)
|
143 |
+
*/
|
144 |
function add_js() {
|
145 |
+
$alert = __( 'Be sure to specify your GMail email address (with the @gmail.com) as the SMTP username, and your GMail password as the SMTP password.', $this->textdomain );
|
146 |
echo <<<JS
|
147 |
<script type="text/javascript">
|
148 |
function configure_gmail() {
|
163 |
JS;
|
164 |
}
|
165 |
|
166 |
+
/**
|
167 |
+
* If the 'Use GMail' option is checked, the GMail settings will override whatever the user may have provided
|
168 |
+
*
|
169 |
+
* @param array $options The options array prior to saving
|
170 |
+
* @return array The options array with GMail settings taking precedence, if relevant
|
171 |
+
*/
|
172 |
+
function maybe_gmail_override( $options ) {
|
173 |
+
// If GMail is to be used, those settings take precendence
|
174 |
+
if ( $options['use_gmail'] )
|
175 |
+
$options = wp_parse_args( $this->gmail_config, $options );
|
176 |
+
return $options;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Sends test e-mail if form was submitted requesting to do so.
|
181 |
+
*
|
182 |
+
*/
|
183 |
+
function maybe_send_test() {
|
184 |
+
if ( isset( $_POST[$this->get_form_submit_name( 'submit_test_email' )] ) ) {
|
185 |
+
check_admin_referer( $this->nonce_field );
|
186 |
+
$user = wp_get_current_user();
|
187 |
+
$email = $user->user_email;
|
188 |
+
$timestamp = current_time( 'mysql' );
|
189 |
+
$message = sprintf( __( 'Hi, this is the %s plugin e-mailing you a test message from your WordPress blog.', $this->textdomain ), $this->name );
|
190 |
+
$message .= "\n\n";
|
191 |
+
$message .= sprintf( __( 'This message was sent with this time-stamp: %s', $this->textdomain ), $timestamp );
|
192 |
+
$message .= "\n\n";
|
193 |
+
$message .= __( 'Congratulations! Your blog is properly configured to send e-mail.', $this->textdomain );
|
194 |
+
wp_mail( $email, __( 'Test message from your WordPress blog', $this->textdomain ), $message );
|
195 |
+
|
196 |
+
// Check success
|
197 |
+
global $phpmailer;
|
198 |
+
if ( $phpmailer->ErrorInfo != "" ) {
|
199 |
+
echo '<div class="error"><p>' . __( 'An error was encountered while trying to send the test e-mail.' ) . '</p>';
|
200 |
+
echo '<blockquote style="font-weight:bold;">';
|
201 |
+
echo '<p>' . $phpmailer->ErrorInfo . '</p>';
|
202 |
+
echo '<p>' . $phpmailer->smtp->error['error'] . '<br />' . $phpmailer->smtp->error['errstr'] . '</p>';
|
203 |
+
echo '</blockquote>';
|
204 |
+
echo '</div>';
|
205 |
+
} else {
|
206 |
+
echo '<div class="updated"><p>' . __( 'Test e-mail sent.', $this->textdomain ) . '</p>';
|
207 |
+
echo '<p>' . sprintf( __( 'The body of the e-mail includes this time-stamp: %s.', $this->textdomain ), $timestamp ) . '</p></div>';
|
208 |
+
}
|
209 |
}
|
210 |
}
|
211 |
|
212 |
+
/*
|
213 |
+
* Outputs form to send test e-mail.
|
214 |
+
*
|
215 |
+
* @return void (Text will be echoed.)
|
216 |
+
*/
|
217 |
+
function send_test_form() {
|
218 |
+
$user = wp_get_current_user();
|
219 |
+
$email = $user->user_email;
|
220 |
+
$action_url = $this->form_action_url();
|
221 |
+
echo '<div class="wrap"><h2><a name="test"></a>' . __( 'Send A Test', $this->textdomain ) . "</h2>\n";
|
222 |
+
echo '<p>' . __( 'Click the button below to send a test email to yourself to see if things are working. Be sure to save any changes you made to the form above before sending the test e-mail. Bear in mind it may take a few minutes for the e-mail to wind its way through the internet.', $this->textdomain ) . "</p>\n";
|
223 |
+
echo '<p>' . sprintf( __( 'This e-mail will be sent to your e-mail address, %s.', $this->textdomain ), $email ) . "</p>\n";
|
224 |
+
echo '<p><em>You must save any changes to the form above before attempting to send a test e-mail.</em></p>';
|
225 |
+
echo "<form name='configure_smtp' action='$action_url' method='post'>\n";
|
226 |
+
wp_nonce_field( $this->nonce_field );
|
227 |
+
echo '<input type="hidden" name="' . $this->get_form_submit_name( 'submit_test_email' ) .'" value="1" />';
|
228 |
+
echo '<div class="submit"><input type="submit" name="Submit" value="' . esc_attr__( 'Send test e-mail', $this->textdomain ) . '" /></div>';
|
229 |
+
echo '</form></div>';
|
230 |
}
|
231 |
|
232 |
+
/**
|
233 |
+
* Configures PHPMailer object during its initialization stage
|
234 |
+
*
|
235 |
+
* @param object $phpmailer PHPMailer object
|
236 |
+
* @return void
|
237 |
+
*/
|
238 |
function phpmailer_init( $phpmailer ) {
|
239 |
$options = $this->get_options();
|
240 |
+
// Don't configure for SMTP if no host is provided.
|
241 |
+
if ( empty( $options['host'] ) )
|
242 |
+
return;
|
243 |
$phpmailer->IsSMTP();
|
244 |
$phpmailer->Host = $options['host'];
|
245 |
$phpmailer->Port = $options['port'] ? $options['port'] : 25;
|
252 |
$phpmailer->SMTPSecure = $options['smtp_secure'];
|
253 |
if ( $options['wordwrap'] > 0 )
|
254 |
$phpmailer->WordWrap = $options['wordwrap'];
|
|
|
255 |
}
|
256 |
|
257 |
+
/**
|
258 |
+
* Configures the "From:" e-mail address for outgoing e-mails
|
259 |
+
*
|
260 |
+
* @param string $from The "from" e-mail address used by WordPress by default
|
261 |
+
* @return string The potentially new "from" e-mail address, if overridden via the plugin's settings.
|
262 |
+
*/
|
263 |
function wp_mail_from( $from ) {
|
264 |
$options = $this->get_options();
|
265 |
if ( $options['from_email'] )
|
267 |
return $from;
|
268 |
}
|
269 |
|
270 |
+
/**
|
271 |
+
* Configures the "From:" name for outgoing e-mails
|
272 |
+
*
|
273 |
+
* @param string $from The "from" name used by WordPress by default
|
274 |
+
* @return string The potentially new "from" name, if overridden via the plugin's settings.
|
275 |
+
*/
|
276 |
function wp_mail_from_name( $from_name ) {
|
277 |
$options = $this->get_options();
|
278 |
if ( $options['from_name'] )
|
279 |
+
$from_name = wp_specialchars_decode( $options['from_name'], ENT_QUOTES );
|
280 |
return $from_name;
|
281 |
}
|
282 |
|
283 |
+
} // end c2c_ConfigureSMTP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
+
$GLOBALS['c2c_configure_smtp'] = new c2c_ConfigureSMTP();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
endif; // end if !class_exists()
|
288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
?>
|
configure-smtp.pot
CHANGED
@@ -1,188 +1,251 @@
|
|
1 |
-
# Translation of the WordPress plugin Configure SMTP
|
2 |
-
# Copyright (C)
|
3 |
# This file is distributed under the same license as the Configure SMTP package.
|
4 |
-
# FIRST AUTHOR <EMAIL@ADDRESS>,
|
5 |
#
|
6 |
#, fuzzy
|
7 |
msgid ""
|
8 |
msgstr ""
|
9 |
-
"Project-Id-Version: Configure SMTP
|
10 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/configure-smtp\n"
|
11 |
-
"POT-Creation-Date:
|
12 |
-
"PO-Revision-Date:
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"MIME-Version: 1.0\n"
|
16 |
"Content-Type: text/plain; charset=utf-8\n"
|
17 |
"Content-Transfer-Encoding: 8bit\n"
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
msgid "Configure SMTP"
|
23 |
msgstr ""
|
24 |
|
25 |
-
#: configure-smtp.php:
|
26 |
msgid "SMTP"
|
27 |
msgstr ""
|
28 |
|
29 |
-
#: configure-smtp.php:
|
30 |
msgid "Send e-mail via GMail?"
|
31 |
msgstr ""
|
32 |
|
33 |
-
#: configure-smtp.php:
|
34 |
msgid ""
|
35 |
"Clicking this will override many of the settings defined below. You will "
|
36 |
"need to input your GMail username and password below."
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: configure-smtp.php:
|
40 |
msgid "SMTP host"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: configure-smtp.php:
|
44 |
msgid ""
|
45 |
"If \"localhost\" doesn't work for you, check with your host for the SMTP "
|
46 |
"hostname."
|
47 |
msgstr ""
|
48 |
|
49 |
-
#: configure-smtp.php:
|
50 |
msgid "SMTP port"
|
51 |
msgstr ""
|
52 |
|
53 |
-
#: configure-smtp.php:
|
54 |
msgid "This is generally 25."
|
55 |
msgstr ""
|
56 |
|
57 |
-
#: configure-smtp.php:
|
58 |
msgid "Secure connection prefix"
|
59 |
msgstr ""
|
60 |
|
61 |
-
#: configure-smtp.php:
|
62 |
msgid ""
|
63 |
"Sets connection prefix for secure connections (prefix method must be "
|
64 |
"supported by your PHP install and your SMTP host)"
|
65 |
msgstr ""
|
66 |
|
67 |
-
#: configure-smtp.php:
|
68 |
msgid "Use SMTPAuth?"
|
69 |
msgstr ""
|
70 |
|
71 |
-
#: configure-smtp.php:
|
72 |
msgid "If checked, you must provide the SMTP username and password below"
|
73 |
msgstr ""
|
74 |
|
75 |
-
#: configure-smtp.php:
|
76 |
msgid "SMTP username"
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: configure-smtp.php:
|
80 |
msgid "SMTP password"
|
81 |
msgstr ""
|
82 |
|
83 |
-
#: configure-smtp.php:
|
84 |
msgid "Wordwrap length"
|
85 |
msgstr ""
|
86 |
|
87 |
-
#: configure-smtp.php:
|
88 |
msgid ""
|
89 |
"Sets word wrapping on the body of the message to a given number of "
|
90 |
"characters."
|
91 |
msgstr ""
|
92 |
|
93 |
-
#: configure-smtp.php:
|
94 |
msgid "Sender e-mail"
|
95 |
msgstr ""
|
96 |
|
97 |
-
#: configure-smtp.php:
|
98 |
msgid ""
|
99 |
-
"Sets the From
|
100 |
"the WordPress default. This value will be used even if you don't enable "
|
101 |
"SMTP. NOTE: This may not take effect depending on your mail server and "
|
102 |
"settings, especially if using SMTPAuth (such as for GMail)."
|
103 |
msgstr ""
|
104 |
|
105 |
-
#: configure-smtp.php:
|
106 |
msgid "Sender name"
|
107 |
msgstr ""
|
108 |
|
109 |
-
#: configure-smtp.php:
|
110 |
msgid ""
|
111 |
"Sets the From name for all outgoing messages. Leave blank to use the "
|
112 |
"WordPress default. This value will be used even if you don't enable SMTP."
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: configure-smtp.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
msgid ""
|
117 |
-
"
|
118 |
-
"
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: configure-smtp.php:
|
122 |
-
|
|
|
|
|
|
|
123 |
msgstr ""
|
124 |
|
125 |
-
#: configure-smtp.php:
|
126 |
-
msgid "
|
|
|
|
|
127 |
msgstr ""
|
128 |
|
129 |
-
#: configure-smtp.php:
|
130 |
#, php-format
|
131 |
msgid ""
|
132 |
"Hi, this is the %s plugin e-mailing you a test message from your WordPress "
|
133 |
"blog."
|
134 |
msgstr ""
|
135 |
|
136 |
-
#: configure-smtp.php:
|
137 |
#, php-format
|
138 |
msgid "This message was sent with this time-stamp: %s"
|
139 |
msgstr ""
|
140 |
|
141 |
-
#: configure-smtp.php:
|
142 |
msgid "Congratulations! Your blog is properly configured to send e-mail."
|
143 |
msgstr ""
|
144 |
|
145 |
-
#: configure-smtp.php:
|
146 |
msgid "Test message from your WordPress blog"
|
147 |
msgstr ""
|
148 |
|
149 |
-
#: configure-smtp.php:
|
150 |
-
msgid "
|
151 |
-
msgstr ""
|
152 |
-
|
153 |
-
#: configure-smtp.php:274
|
154 |
-
#, php-format
|
155 |
-
msgid "The body of the e-mail includes this time-stamp: %s."
|
156 |
-
msgstr ""
|
157 |
-
|
158 |
-
#: configure-smtp.php:280
|
159 |
-
msgid "A plugin by coffee2code"
|
160 |
-
msgstr ""
|
161 |
-
|
162 |
-
#: configure-smtp.php:281
|
163 |
-
msgid "Configure SMTP Settings"
|
164 |
msgstr ""
|
165 |
|
166 |
-
#: configure-smtp.php:
|
167 |
-
msgid "
|
168 |
msgstr ""
|
169 |
|
170 |
-
#: configure-smtp.php:
|
171 |
#, php-format
|
172 |
-
msgid ""
|
173 |
-
"After you've configured your SMTP settings, use the %s to send a test "
|
174 |
-
"message to yourself."
|
175 |
-
msgstr ""
|
176 |
-
|
177 |
-
#: configure-smtp.php:339
|
178 |
-
msgid "Save Changes"
|
179 |
msgstr ""
|
180 |
|
181 |
-
#: configure-smtp.php:
|
182 |
msgid "Send A Test"
|
183 |
msgstr ""
|
184 |
|
185 |
-
#: configure-smtp.php:
|
186 |
msgid ""
|
187 |
"Click the button below to send a test email to yourself to see if things are "
|
188 |
"working. Be sure to save any changes you made to the form above before "
|
@@ -190,29 +253,29 @@ msgid ""
|
|
190 |
"mail to wind its way through the internet."
|
191 |
msgstr ""
|
192 |
|
193 |
-
#: configure-smtp.php:
|
194 |
#, php-format
|
195 |
msgid "This e-mail will be sent to your e-mail address, %s."
|
196 |
msgstr ""
|
197 |
|
198 |
-
#: configure-smtp.php:
|
199 |
msgid "Send test e-mail"
|
200 |
msgstr ""
|
201 |
|
202 |
-
#. Plugin URI of
|
203 |
-
msgid "http://coffee2code.com/wp-plugins/configure-smtp"
|
204 |
msgstr ""
|
205 |
|
206 |
-
#. Description of
|
207 |
msgid ""
|
208 |
"Configure SMTP mailing in WordPress, including support for sending e-mail "
|
209 |
"via SSL/TLS (such as GMail)."
|
210 |
msgstr ""
|
211 |
|
212 |
-
#. Author of
|
213 |
msgid "Scott Reilly"
|
214 |
msgstr ""
|
215 |
|
216 |
-
#. Author URI of
|
217 |
msgid "http://coffee2code.com"
|
218 |
msgstr ""
|
1 |
+
# Translation of the WordPress plugin Configure SMTP 3.0 by Scott Reilly.
|
2 |
+
# Copyright (C) 2010 Scott Reilly
|
3 |
# This file is distributed under the same license as the Configure SMTP package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
|
5 |
#
|
6 |
#, fuzzy
|
7 |
msgid ""
|
8 |
msgstr ""
|
9 |
+
"Project-Id-Version: Configure SMTP 3.0\n"
|
10 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/configure-smtp\n"
|
11 |
+
"POT-Creation-Date: 2010-09-28 11:43-0400\n"
|
12 |
+
"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"MIME-Version: 1.0\n"
|
16 |
"Content-Type: text/plain; charset=utf-8\n"
|
17 |
"Content-Transfer-Encoding: 8bit\n"
|
18 |
|
19 |
+
#: c2c-plugin.php:59
|
20 |
+
#, php-format
|
21 |
+
msgid "Invalid file specified for C2C_Plugin: %s"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: c2c-plugin.php:241
|
25 |
+
msgid "Settings reset."
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: c2c-plugin.php:252 c2c-plugin.php:260
|
29 |
+
#, php-format
|
30 |
+
msgid "A value is required for: \"%s\""
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: c2c-plugin.php:269
|
34 |
+
#, php-format
|
35 |
+
msgid "Expected integer value for: %s"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: c2c-plugin.php:380
|
39 |
+
#, php-format
|
40 |
+
msgid "More information about %1$s %2$s"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: c2c-plugin.php:381
|
44 |
+
msgid "Click for more help on this plugin"
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: c2c-plugin.php:382
|
48 |
+
msgid " (especially check out the \"Other Notes\" tab, if present)"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: c2c-plugin.php:473
|
52 |
+
msgid "Settings"
|
53 |
+
msgstr ""
|
54 |
+
|
55 |
+
#: c2c-plugin.php:703
|
56 |
+
msgid "See the \"Help\" link to the top-right of the page for more help."
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: c2c-plugin.php:721
|
60 |
+
msgid "A plugin by coffee2code"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: c2c-plugin.php:732
|
64 |
+
msgid "Save Changes"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: c2c-plugin.php:733
|
68 |
+
msgid "Reset Settings"
|
69 |
+
msgstr ""
|
70 |
+
|
71 |
+
#: c2c-plugin.php:739
|
72 |
+
msgid "Scott Reilly, aka coffee2code"
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: c2c-plugin.php:740
|
76 |
+
#, php-format
|
77 |
+
msgid "This plugin brought to you by %s."
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: c2c-plugin.php:741
|
81 |
+
msgid "Please consider a donation"
|
82 |
+
msgstr ""
|
83 |
+
|
84 |
+
#: c2c-plugin.php:742
|
85 |
+
msgid "Did you find this plugin useful?"
|
86 |
+
msgstr ""
|
87 |
+
|
88 |
+
#. #-#-#-#-# configure-smtp.pot (Configure SMTP 3.0) #-#-#-#-#
|
89 |
+
#. Plugin Name of the plugin/theme
|
90 |
+
#: configure-smtp.php:68
|
91 |
msgid "Configure SMTP"
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: configure-smtp.php:69
|
95 |
msgid "SMTP"
|
96 |
msgstr ""
|
97 |
|
98 |
+
#: configure-smtp.php:73
|
99 |
msgid "Send e-mail via GMail?"
|
100 |
msgstr ""
|
101 |
|
102 |
+
#: configure-smtp.php:74
|
103 |
msgid ""
|
104 |
"Clicking this will override many of the settings defined below. You will "
|
105 |
"need to input your GMail username and password below."
|
106 |
msgstr ""
|
107 |
|
108 |
+
#: configure-smtp.php:77
|
109 |
msgid "SMTP host"
|
110 |
msgstr ""
|
111 |
|
112 |
+
#: configure-smtp.php:78
|
113 |
msgid ""
|
114 |
"If \"localhost\" doesn't work for you, check with your host for the SMTP "
|
115 |
"hostname."
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: configure-smtp.php:80
|
119 |
msgid "SMTP port"
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: configure-smtp.php:81
|
123 |
msgid "This is generally 25."
|
124 |
msgstr ""
|
125 |
|
126 |
+
#: configure-smtp.php:83
|
127 |
msgid "Secure connection prefix"
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: configure-smtp.php:85
|
131 |
msgid ""
|
132 |
"Sets connection prefix for secure connections (prefix method must be "
|
133 |
"supported by your PHP install and your SMTP host)"
|
134 |
msgstr ""
|
135 |
|
136 |
+
#: configure-smtp.php:87
|
137 |
msgid "Use SMTPAuth?"
|
138 |
msgstr ""
|
139 |
|
140 |
+
#: configure-smtp.php:88
|
141 |
msgid "If checked, you must provide the SMTP username and password below"
|
142 |
msgstr ""
|
143 |
|
144 |
+
#: configure-smtp.php:90
|
145 |
msgid "SMTP username"
|
146 |
msgstr ""
|
147 |
|
148 |
+
#: configure-smtp.php:93
|
149 |
msgid "SMTP password"
|
150 |
msgstr ""
|
151 |
|
152 |
+
#: configure-smtp.php:96
|
153 |
msgid "Wordwrap length"
|
154 |
msgstr ""
|
155 |
|
156 |
+
#: configure-smtp.php:97
|
157 |
msgid ""
|
158 |
"Sets word wrapping on the body of the message to a given number of "
|
159 |
"characters."
|
160 |
msgstr ""
|
161 |
|
162 |
+
#: configure-smtp.php:100
|
163 |
msgid "Sender e-mail"
|
164 |
msgstr ""
|
165 |
|
166 |
+
#: configure-smtp.php:101
|
167 |
msgid ""
|
168 |
+
"Sets the From e-mail address for all outgoing messages. Leave blank to use "
|
169 |
"the WordPress default. This value will be used even if you don't enable "
|
170 |
"SMTP. NOTE: This may not take effect depending on your mail server and "
|
171 |
"settings, especially if using SMTPAuth (such as for GMail)."
|
172 |
msgstr ""
|
173 |
|
174 |
+
#: configure-smtp.php:103
|
175 |
msgid "Sender name"
|
176 |
msgstr ""
|
177 |
|
178 |
+
#: configure-smtp.php:104
|
179 |
msgid ""
|
180 |
"Sets the From name for all outgoing messages. Leave blank to use the "
|
181 |
"WordPress default. This value will be used even if you don't enable SMTP."
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: configure-smtp.php:132
|
185 |
+
msgid "Configure SMTP Settings"
|
186 |
+
msgstr ""
|
187 |
+
|
188 |
+
#: configure-smtp.php:133
|
189 |
+
msgid "test"
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: configure-smtp.php:135
|
193 |
msgid ""
|
194 |
+
"SMTP mailing is currently <strong>NOT ENABLED</strong> because no SMTP host "
|
195 |
+
"has been specified."
|
196 |
msgstr ""
|
197 |
|
198 |
+
#: configure-smtp.php:136
|
199 |
+
#, php-format
|
200 |
+
msgid ""
|
201 |
+
"After you have configured your SMTP settings, use the %s to send a test "
|
202 |
+
"message to yourself."
|
203 |
msgstr ""
|
204 |
|
205 |
+
#: configure-smtp.php:145
|
206 |
+
msgid ""
|
207 |
+
"Be sure to specify your GMail email address (with the @gmail.com) as the "
|
208 |
+
"SMTP username, and your GMail password as the SMTP password."
|
209 |
msgstr ""
|
210 |
|
211 |
+
#: configure-smtp.php:189
|
212 |
#, php-format
|
213 |
msgid ""
|
214 |
"Hi, this is the %s plugin e-mailing you a test message from your WordPress "
|
215 |
"blog."
|
216 |
msgstr ""
|
217 |
|
218 |
+
#: configure-smtp.php:191
|
219 |
#, php-format
|
220 |
msgid "This message was sent with this time-stamp: %s"
|
221 |
msgstr ""
|
222 |
|
223 |
+
#: configure-smtp.php:193
|
224 |
msgid "Congratulations! Your blog is properly configured to send e-mail."
|
225 |
msgstr ""
|
226 |
|
227 |
+
#: configure-smtp.php:194
|
228 |
msgid "Test message from your WordPress blog"
|
229 |
msgstr ""
|
230 |
|
231 |
+
#: configure-smtp.php:199
|
232 |
+
msgid "An error was encountered while trying to send the test e-mail."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
msgstr ""
|
234 |
|
235 |
+
#: configure-smtp.php:206
|
236 |
+
msgid "Test e-mail sent."
|
237 |
msgstr ""
|
238 |
|
239 |
+
#: configure-smtp.php:207
|
240 |
#, php-format
|
241 |
+
msgid "The body of the e-mail includes this time-stamp: %s."
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
msgstr ""
|
243 |
|
244 |
+
#: configure-smtp.php:221
|
245 |
msgid "Send A Test"
|
246 |
msgstr ""
|
247 |
|
248 |
+
#: configure-smtp.php:222
|
249 |
msgid ""
|
250 |
"Click the button below to send a test email to yourself to see if things are "
|
251 |
"working. Be sure to save any changes you made to the form above before "
|
253 |
"mail to wind its way through the internet."
|
254 |
msgstr ""
|
255 |
|
256 |
+
#: configure-smtp.php:223
|
257 |
#, php-format
|
258 |
msgid "This e-mail will be sent to your e-mail address, %s."
|
259 |
msgstr ""
|
260 |
|
261 |
+
#: configure-smtp.php:228
|
262 |
msgid "Send test e-mail"
|
263 |
msgstr ""
|
264 |
|
265 |
+
#. Plugin URI of the plugin/theme
|
266 |
+
msgid "http://coffee2code.com/wp-plugins/configure-smtp/"
|
267 |
msgstr ""
|
268 |
|
269 |
+
#. Description of the plugin/theme
|
270 |
msgid ""
|
271 |
"Configure SMTP mailing in WordPress, including support for sending e-mail "
|
272 |
"via SSL/TLS (such as GMail)."
|
273 |
msgstr ""
|
274 |
|
275 |
+
#. Author of the plugin/theme
|
276 |
msgid "Scott Reilly"
|
277 |
msgstr ""
|
278 |
|
279 |
+
#. Author URI of the plugin/theme
|
280 |
msgid "http://coffee2code.com"
|
281 |
msgstr ""
|
readme.txt
CHANGED
@@ -3,12 +3,13 @@ Contributors: coffee2code
|
|
3 |
Donate link: http://coffee2code.com/donate
|
4 |
Tags: email, smtp, gmail, sendmail, wp_mail, phpmailer, outgoing mail, tls, ssl, security, privacy, wp-phpmailer, coffee2code
|
5 |
Requires at least: 2.8
|
6 |
-
Tested up to:
|
7 |
-
Stable tag:
|
8 |
-
Version:
|
9 |
|
10 |
Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
|
11 |
|
|
|
12 |
== Description ==
|
13 |
|
14 |
Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
|
@@ -30,6 +31,7 @@ Regardless of whether SMTP is enabled, the plugin provides you the ability to de
|
|
30 |
|
31 |
A simple test button is also available that allows you to send a test e-mail to yourself to check if sending e-mail has been properly configured for your blog.
|
32 |
|
|
|
33 |
== Installation ==
|
34 |
|
35 |
1. Unzip `configure-smtp.zip` inside the `/wp-content/plugins/` directory (or install via the built-in WordPress plugin installer)
|
@@ -37,6 +39,7 @@ A simple test button is also available that allows you to send a test e-mail to
|
|
37 |
1. Click the plugin's `Settings` link next to its `Deactivate` link (still on the Plugins page), or click on the `Settings` -> `SMTP` link, to go to the plugin's admin settings page. Optionally customize the settings (to configure it if the defaults aren't valid for your situation).
|
38 |
1. (optional) Use the built-in test to see if your blog can properly send out e-mails.
|
39 |
|
|
|
40 |
== Frequently Asked Questions ==
|
41 |
|
42 |
= I am already able to receive e-mail sent by my blog, so would I have any use or need for this plugin? =
|
@@ -51,12 +54,37 @@ Check out the settings for your local e-mail program. More than likely that is
|
|
51 |
|
52 |
If your settings worked, you should receive the test e-mail at the e-mail address associated with your WordPress blog user account. That e-mail contains a time-stamp which was reported to you by the plugin when the e-mail was sent. If you are trying out various setting values, be sure to record what your settings were and what the time-stamp was when sending with those settings.
|
53 |
|
|
|
54 |
== Screenshots ==
|
55 |
|
56 |
1. A screenshot of the plugin's admin settings page.
|
57 |
|
|
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
= 2.7 =
|
61 |
* Fix to prevent HTML entities from appearing in the From name value in outgoing e-mails
|
62 |
* Added full support for localization
|
@@ -100,3 +128,8 @@ If your settings worked, you should receive the test e-mail at the e-mail addres
|
|
100 |
= pre-2.0 =
|
101 |
* Earlier versions of this plugin existed as my wpPHPMailer plugin, which due to the inclusion of PHPMailer within WordPress's core and necessary changes to the plugin warranted a rebranding/renaming.
|
102 |
|
|
|
|
|
|
|
|
|
|
3 |
Donate link: http://coffee2code.com/donate
|
4 |
Tags: email, smtp, gmail, sendmail, wp_mail, phpmailer, outgoing mail, tls, ssl, security, privacy, wp-phpmailer, coffee2code
|
5 |
Requires at least: 2.8
|
6 |
+
Tested up to: 3.0.1
|
7 |
+
Stable tag: 3.0
|
8 |
+
Version: 3.0
|
9 |
|
10 |
Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
|
11 |
|
12 |
+
|
13 |
== Description ==
|
14 |
|
15 |
Configure SMTP mailing in WordPress, including support for sending e-mail via SSL/TLS (such as GMail).
|
31 |
|
32 |
A simple test button is also available that allows you to send a test e-mail to yourself to check if sending e-mail has been properly configured for your blog.
|
33 |
|
34 |
+
|
35 |
== Installation ==
|
36 |
|
37 |
1. Unzip `configure-smtp.zip` inside the `/wp-content/plugins/` directory (or install via the built-in WordPress plugin installer)
|
39 |
1. Click the plugin's `Settings` link next to its `Deactivate` link (still on the Plugins page), or click on the `Settings` -> `SMTP` link, to go to the plugin's admin settings page. Optionally customize the settings (to configure it if the defaults aren't valid for your situation).
|
40 |
1. (optional) Use the built-in test to see if your blog can properly send out e-mails.
|
41 |
|
42 |
+
|
43 |
== Frequently Asked Questions ==
|
44 |
|
45 |
= I am already able to receive e-mail sent by my blog, so would I have any use or need for this plugin? =
|
54 |
|
55 |
If your settings worked, you should receive the test e-mail at the e-mail address associated with your WordPress blog user account. That e-mail contains a time-stamp which was reported to you by the plugin when the e-mail was sent. If you are trying out various setting values, be sure to record what your settings were and what the time-stamp was when sending with those settings.
|
56 |
|
57 |
+
|
58 |
== Screenshots ==
|
59 |
|
60 |
1. A screenshot of the plugin's admin settings page.
|
61 |
|
62 |
+
|
63 |
== Changelog ==
|
64 |
|
65 |
+
= 3.0 =
|
66 |
+
* Re-implementation by extending C2C_Plugin_016, which among other things adds support for:
|
67 |
+
* Reset of options to default values
|
68 |
+
* Better sanitization of input values
|
69 |
+
* Offload of core/basic functionality to generic plugin framework
|
70 |
+
* Additional hooks for various stages/places of plugin operation
|
71 |
+
* Easier localization support
|
72 |
+
* Add error checking and reporting when attempting to send test e-mail
|
73 |
+
* Don't configure the mailer to use SMTP if no host is provided
|
74 |
+
* Fix localization support
|
75 |
+
* Store plugin instance in global variable, $c2c_configure_smtp, to allow for external manipulation
|
76 |
+
* Rename class from 'ConfigureSMTP' to 'c2c_ConfigureSMTP'
|
77 |
+
* Remove docs from top of plugin file (all that and more are in readme.txt)
|
78 |
+
* Note compatibility with WP 3.0+
|
79 |
+
* Minor tweaks to code formatting (spacing)
|
80 |
+
* Add Upgrade Notice section to readme.txt
|
81 |
+
* Add PHPDoc documentation
|
82 |
+
* Add package info to top of file
|
83 |
+
* Update copyright date
|
84 |
+
* Remove trailing whitespace
|
85 |
+
* Update screenshot
|
86 |
+
* Update .pot file
|
87 |
+
|
88 |
= 2.7 =
|
89 |
* Fix to prevent HTML entities from appearing in the From name value in outgoing e-mails
|
90 |
* Added full support for localization
|
128 |
= pre-2.0 =
|
129 |
* Earlier versions of this plugin existed as my wpPHPMailer plugin, which due to the inclusion of PHPMailer within WordPress's core and necessary changes to the plugin warranted a rebranding/renaming.
|
130 |
|
131 |
+
|
132 |
+
== Upgrade Notice ==
|
133 |
+
|
134 |
+
= 3.0 =
|
135 |
+
Recommended update! This release includes a major re-implementation, bug fixes, localization support, and more.
|
screenshot-1.png
CHANGED
Binary file
|