Swap JS actions with filters for robustness & testability, get rid of URL key hashing [PREMIUM-2]
This commit is contained in:
@@ -103,7 +103,7 @@ define(
|
||||
}
|
||||
];
|
||||
|
||||
Hooks.doAction('mailpoet_newsletters_3rd_step_fields', fields);
|
||||
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
|
||||
|
||||
return {
|
||||
getFields: function(newsletter) {
|
||||
|
@@ -413,7 +413,7 @@ define(
|
||||
}
|
||||
];
|
||||
|
||||
Hooks.doAction('mailpoet_newsletters_3rd_step_fields', fields);
|
||||
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
|
||||
|
||||
return {
|
||||
getFields: function(newsletter) {
|
||||
|
@@ -73,7 +73,7 @@ define(
|
||||
}
|
||||
];
|
||||
|
||||
Hooks.doAction('mailpoet_newsletters_3rd_step_fields', fields);
|
||||
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
|
||||
|
||||
return {
|
||||
getFields: function(newsletter) {
|
||||
|
@@ -73,9 +73,9 @@ class Links {
|
||||
$processed_links = array();
|
||||
foreach($extracted_links as $extracted_link) {
|
||||
$hash = Security::generateRandomString(self::HASH_LENGTH);
|
||||
// Use a hashed key to map between extracted and processed links
|
||||
// Use URL as a key to map between extracted and processed links
|
||||
// regardless of their sequential position (useful for link skips etc.)
|
||||
$key = self::getKey($extracted_link['link']);
|
||||
$key = $extracted_link['link'];
|
||||
$processed_links[$key] = array(
|
||||
'hash' => $hash,
|
||||
'url' => $extracted_link['link'],
|
||||
@@ -89,9 +89,8 @@ class Links {
|
||||
|
||||
static function replace($content, $extracted_links, $processed_links) {
|
||||
foreach($extracted_links as $key => $extracted_link) {
|
||||
$key = self::getKey($extracted_link['link']);
|
||||
if(!isset($processed_links[$key]['processed_link'])) {
|
||||
// Skip this link
|
||||
$key = $extracted_link['link'];
|
||||
if(!($hasReplacement = isset($processed_links[$key]['processed_link']))) {
|
||||
continue;
|
||||
}
|
||||
$processed_link = $processed_links[$key]['processed_link'];
|
||||
@@ -113,6 +112,7 @@ class Links {
|
||||
'[$1](' . $processed_link . ')',
|
||||
$content
|
||||
);
|
||||
// Clean up data used to generate a new link
|
||||
unset($processed_links[$key]['processed_link']);
|
||||
}
|
||||
return array(
|
||||
@@ -121,10 +121,6 @@ class Links {
|
||||
);
|
||||
}
|
||||
|
||||
static function getKey($value) {
|
||||
return md5($value);
|
||||
}
|
||||
|
||||
static function replaceSubscriberData(
|
||||
$subscriber_id,
|
||||
$queue_id,
|
||||
|
Reference in New Issue
Block a user