plugin_slug;
}
/**
* Load Text Domain Language Support
*
* @since 1.0
*/
public function load_plugin_textdomain() {
$plugin_basename = plugin_basename(plugin_dir_path(__DIR__) . $this->plugin_slug . '.php');
load_plugin_textdomain('admin-personalize', false, dirname($plugin_basename) . '/languages/');
}
/**
* Filter: admin_personalize_from_name
*
* @since 1.0
*
* @param string $name Default name.
* @return string WP Mail From name.
*/
public function admin_personalize_from_name($name) {
$admin_personalize_name = get_option('admin_personalize_name', '');
if (!empty($admin_personalize_name) && !$this->is_default_from_name($admin_personalize_name)) {
return $admin_personalize_name;
}
return $name;
}
/**
* Filter: admin_personalize_from
*
* @since 1.0
*
* @param string $name Default email.
* @return string WP Mail From email.
*/
public function admin_personalize_from($email) {
$admin_personalize_email = get_option('admin_personalize_email', '');
if (!empty($admin_personalize_email) && is_email($admin_personalize_email)) {
$override_default = get_option('admin_personalize_override_default', 0);
$override_admin = get_option('admin_personalize_override_admin', 0);
if ($override_default == 1 && $this->is_default_from($email)) {
return $admin_personalize_email;
}
if ($override_admin == 1 && $this->is_admin_from($email)) {
return $admin_personalize_email;
}
}
return $email;
}
/**
* Is Default From Name
*
* Checks to see if the name is the default name assigned by WordPress.
* This is defined in admin_personalize() in wp-includes/pluggable.php
*
* @since 1.0
*
* @param string $name Name to check.
* @return boolean
*/
public function is_default_from_name($name) {
if ($name == 'WordPress')
return true;
return false;
}
/**
* Is Default From Email
*
* @since 1.0
*
* @param string $email Email to check.
* @return boolean
*/
public function is_default_from($email) {
$default_email = $this->get_default_from();
if ($email == $default_email)
return true;
return false;
}
/**
* Get Default From Email
*
* Checks to see if the email is the default address assigned by WordPress.
* This is defined in admin_personalize() in wp-includes/pluggable.php
*
* The 'admin_personalize_default_from' filter is provided so you can add compatibility when
* the pluggable admin_personalize() function is altered to use a different default email address.
*
* Also note, some hosts may refuse to relay mail from an unknown domain. See
* http://trac.wordpress.org/ticket/5007
*
* @since 1.0
*
* @return string Default from email.
*/
public function get_default_from() {
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
return apply_filters('admin_personalize_default_from', 'wordpress@' . $sitename);
}
/**
* Is Admin From Email
*
* Checks to see if the email is the admin email address set in the WordPress options.
*
* Also note, some hosts may refuse to relay mail from an unknown domain. See
* http://trac.wordpress.org/ticket/5007
*
* @since 1.0
*
* @param string $email Email to check.
* @return boolean
*/
public function is_admin_from($email) {
$admin_email = get_option('admin_email');
if ($email == $admin_email)
return true;
return false;
}
/**
* Register Activation
*
* Called when plugin is activated. Not called when plugin is auto-updated.
*
* @since 1.0
*/
public static function activate() {
// Copy values from original WP MailFrom if present and plugin optionsnot yet set.
// http://wordpress.org/plugins/wp-mailfrom/
$name = get_option('site_mail_from_name', '');
$email = get_option('site_mail_from_email', '');
$new_name = get_option('admin_personalize_name', '');
$new_email = get_option('admin_personalize_email', '');
if (!empty($name) && empty($new_name))
$name_updated = add_option('admin_personalize_name', $name);
if (!empty($email) && empty($new_email))
$email_updated = add_option('admin_personalize_email', $email);
}
/**
* Configure WordPress icon
*
* @since 1.1
*/
public function admin_personalize_custom_wp_icon() {
if (!empty(get_option('admin_personalize_configure_wp_icon'))) {
?>