- Removes unused properties from Links class and converts methods to

static
This commit is contained in:
Vlad
2016-04-16 16:48:35 -04:00
parent cb3d49f200
commit 1f26079b5f
2 changed files with 4 additions and 18 deletions

View File

@ -180,8 +180,7 @@ class SendingQueue {
} }
function processLinks($text, $newsletter_id, $queue_id) { function processLinks($text, $newsletter_id, $queue_id) {
$links = new Links(); list($text, $processed_links) = Links::replace($text);
list($text, $processed_links) = $links->replace($text);
foreach($processed_links as $link) { foreach($processed_links as $link) {
// save extracted and processed links // save extracted and processed links
$newsletter_link = NewsletterLink::create(); $newsletter_link = NewsletterLink::create();

View File

@ -5,20 +5,7 @@ use MailPoet\Newsletter\Shortcodes\Shortcodes;
use MailPoet\Util\Security; use MailPoet\Util\Security;
class Links { class Links {
public $newsletter_id; static function extract($text) {
public $queue_id;
public $subscriber_id;
function __construct(
$newsletter_id = false,
$subscriber_id = false,
$queue_id = false) {
$this->newsletter_id = $newsletter_id;
$this->queue_id = $queue_id;
$this->subscriber_id = $subscriber_id;
}
function extract($text) {
// adopted from WP's wp_extract_urls() function & modified to work on hrefs // adopted from WP's wp_extract_urls() function & modified to work on hrefs
# match href=' or href=" # match href=' or href="
$regex = '#(?:href.*?=.*?)(["\']?)(' $regex = '#(?:href.*?=.*?)(["\']?)('
@ -45,8 +32,8 @@ class Links {
); );
} }
function replace($text, $links = false) { static function replace($text, $links = false) {
$links = ($links) ? $links : $this->extract($text); $links = ($links) ? $links : self::extract($text);
$processed_links = array(); $processed_links = array();
foreach($links as $link) { foreach($links as $link) {
$hash = Security::generateRandomString(5); $hash = Security::generateRandomString(5);