Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tracking as an option #17

Merged
merged 19 commits into from
Mar 18, 2016
Merged

Adding tracking as an option #17

merged 19 commits into from
Mar 18, 2016

Conversation

max-mathieu
Copy link
Contributor

No description provided.

@@ -32,7 +32,7 @@ public function add_plugin_page()

protected function render_message($msg, $msg_type = 'error')
{
echo "<div class='$msg_type notice is-dismissible'><p>$msg</p></div>";
echo '<div class="' . $msg_type . ' notice is-dismissible"><p>$msg</p></div>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think using sprintf or printf is even better than this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, and I did not realize that there was $msg in it too.

@@ -21,6 +21,13 @@ public function configure_phpmailer($phpmailer) {
if(!$options['enable_sparkpost'] || empty($options['password'])) {
return;
}
$tracking_enabled = !!$options['enable_tracking'];
$x_msys_api => array(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$x_msys_api = array(

Seems you didn't run it ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not have time yet

@rajumsys
Copy link
Contributor

Here are a few more observations:

  1. Tracking option should not be a checkbox. It should be dropdown to allow 3 options
<option>Default</option>
<option>Yes</option>
<option>No</option>

Now, we always setting the tracking to either true or false. But we should have an option to use system default. So, we default is selected, we won't pass the options at all, leaving it to default behaviour.

  1. So it'll make more sense to put this field in the override section.

@@ -32,7 +32,7 @@ public function add_plugin_page()

protected function render_message($msg, $msg_type = 'error')
{
printf('<div class="%s notice is-dismissible"><p>$msg</p></div>', $msg_type);
printf('<div class="%s notice is-dismissible"><p>%s</p></div>', $msg_type, $msg);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, I had fixed that locally. Probably forgot to push before leaving

@max-mathieu
Copy link
Contributor Author

  1. Tracking option should not be a checkbox. It should be dropdown to allow 3 options
  2. So it'll make more sense to put this field in the override section.

I disagree. The default for tracking can be set at various levels (system, per account, per template) and they can be different between SMTP and API at those levels. There's no simple way to expose it here, and at the end of the day, users want either to track or not, so showing a "Default" without saying what it is does not help much

@rob
Copy link

rob commented Mar 17, 2016

Hopefully this gets merged soon! We're switching from Mandrill and just ran into an issue related to this.

We're trying to use the HTTP API version (instead of SMTP), but the open_tracking and click_tracking options are being set to true automatically (by SparkPost) even though we've disabled both of them under 'Engagement Tracking' in SparkPost's web interface. It seems that only applies to SMTP sending, not for the HTTP API (which sets them to true by default.)

Thanks for your work on this @max-mathieu! I appreciate it. I was going to work on the same thing until I saw this PR.

@@ -28,9 +28,9 @@
}
$sp = new SparkPost();

if ($sp->get_option('enable_sparkpost')) {
if ($sp::get_option('enable_sparkpost')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we do SparkPost:: instead of $sp:: ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am even wonder how it works! Seems I can call static method through instance which is weird.

Ok, I see why it works

A property declared as static cannot be accessed with an instantiated class object (though a static method can).

So back to your question, why that's preferred while language supports this.

* @return array
*/
protected function get_headers_in_content()
protected function get_reply_to($body_content)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems $body_content not used. So we can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, I planned to pass $body['content'] as reference there and changed my mind :)

@rajumsys rajumsys mentioned this pull request Mar 18, 2016
@@ -48,7 +48,7 @@ public function sp_deactivate()

static function get_options()
{
return array_merge(self::$options_default, get_option('sp_settings'));
return array_merge(self::$options_default, get_option('sp_settings', []));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be array() for php < 5.4

rajumsys added a commit that referenced this pull request Mar 18, 2016
@rajumsys rajumsys merged commit 38c9bf0 into master Mar 18, 2016
maxharrisnet pushed a commit that referenced this pull request Sep 17, 2020
maxharrisnet pushed a commit that referenced this pull request Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants