diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-02-17 20:56:03 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-02-17 20:56:03 +0000 |
commit | f627e0d82c18a1ed60eead38ce38746ded43adc6 (patch) | |
tree | 0a3ef3c2266b717a3880c0c4c6edcdc3aae7c275 /Postman/PostmanInstaller.php | |
parent | a04f57be50a9ce581d8a48acd817d2788958a1dd (diff) | |
download | Post-SMTP-f627e0d82c18a1ed60eead38ce38746ded43adc6.zip |
= 1.9.7 - 2019-02-17
* New: Fallback Feature - Configure a backup SMTP when emails are failing.
* New: WordPress Multisite compability - with global settings.
* New: Email Log capability - give other user cheking the logs.
* Fixed: compatibility with mailster plugin
* Fixed: Mandrill exception bug - Thanks to Niels de Blaauw from Level-Level
Diffstat (limited to 'Postman/PostmanInstaller.php')
-rw-r--r-- | Postman/PostmanInstaller.php | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/Postman/PostmanInstaller.php b/Postman/PostmanInstaller.php index 4b2603b..f011251 100644 --- a/Postman/PostmanInstaller.php +++ b/Postman/PostmanInstaller.php @@ -12,6 +12,8 @@ require_once( 'PostmanOptions.php' ); class PostmanInstaller { private $logger; + private $roles; + /** */ public function __construct() { @@ -22,16 +24,39 @@ class PostmanInstaller { * Handle activation of the plugin */ public function activatePostman() { + $options = get_option( PostmanOptions::POSTMAN_OPTIONS ); + $args = array( + 'fallback_smtp_enabled' => 'no', + ); + + if ( empty( $options ) ) { + add_option( 'postman_options', $args ); + + } else { + if ( empty( $options['fallback_smtp_enabled'] ) ) { + $result = array_merge($options, $args); + update_option( PostmanOptions::POSTMAN_OPTIONS, $result ); + } + } + if ( function_exists( 'is_multisite' ) && is_multisite() ) { + +/* $role = get_role( Postman::ADMINISTRATOR_ROLE_NAME ); + $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME ); + $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );*/ + + $options['post_smtp_allow_overwrite'] = '1'; + update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options ); + // handle network activation // from https://wordpress.org/support/topic/new-function-wp_get_sites?replies=11 // run the activation function for each blog id $old_blog = get_current_blog_id(); // Get all blog ids - $subsites = wp_get_sites(); + $subsites = get_sites(); foreach ( $subsites as $subsite ) { - $this->logger->trace( 'multisite: switching to blog ' . $subsite ['blog_id'] ); - switch_to_blog( $subsite ['blog_id'] ); + $this->logger->trace( 'multisite: switching to blog ' . $subsite->blog_id ); + switch_to_blog( $subsite->blog_id ); $this->handleOptionUpdates(); $this->addCapability(); } @@ -65,10 +90,10 @@ class PostmanInstaller { // run the deactivation function for each blog id $old_blog = get_current_blog_id(); // Get all blog ids - $subsites = wp_get_sites(); + $subsites = get_sites(); foreach ( $subsites as $subsite ) { - $this->logger->trace( 'multisite: switching to blog ' . $subsite ['blog_id'] ); - switch_to_blog( $subsite ['blog_id'] ); + $this->logger->trace( 'multisite: switching to blog ' . $subsite->blog_id ); + switch_to_blog( $subsite->blog_id ); $this->removeCapability(); } switch_to_blog( $old_blog ); @@ -90,6 +115,7 @@ class PostmanInstaller { // add the custom capability to the administrator role $role = get_role( Postman::ADMINISTRATOR_ROLE_NAME ); $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME ); + $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS ); } /** @@ -104,6 +130,7 @@ class PostmanInstaller { // remove the custom capability from the administrator role $role = get_role( Postman::ADMINISTRATOR_ROLE_NAME ); $role->remove_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME ); + $role->remove_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS ); } /** |