Move data for GA to free
[MAILPOET-2397]
This commit is contained in:
committed by
Jack Kitterhing
parent
780f7a30c0
commit
787cd8373a
@@ -282,6 +282,7 @@ class Migrator {
|
|||||||
'updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
'updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
'deleted_at timestamp NULL,',
|
'deleted_at timestamp NULL,',
|
||||||
'unsubscribe_token char(15) NULL,',
|
'unsubscribe_token char(15) NULL,',
|
||||||
|
'ga_campaign varchar(250) NOT NULL DEFAULT "",',
|
||||||
'PRIMARY KEY (id),',
|
'PRIMARY KEY (id),',
|
||||||
'UNIQUE KEY unsubscribe_token (unsubscribe_token),',
|
'UNIQUE KEY unsubscribe_token (unsubscribe_token),',
|
||||||
'KEY type_status (type,status)',
|
'KEY type_status (type,status)',
|
||||||
|
@@ -176,6 +176,7 @@ class Populator {
|
|||||||
$this->detectReferral();
|
$this->detectReferral();
|
||||||
$this->updateFormsSuccessMessages();
|
$this->updateFormsSuccessMessages();
|
||||||
$this->initWooCommerceTransactionalEmails();
|
$this->initWooCommerceTransactionalEmails();
|
||||||
|
$this->moveGoogleAnalyticsFromPremium();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createMailPoetPage() {
|
private function createMailPoetPage() {
|
||||||
@@ -692,6 +693,37 @@ class Populator {
|
|||||||
$this->settings->set(Worker::SETTINGS_KEY, $settings);
|
$this->settings->set(Worker::SETTINGS_KEY, $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function moveGoogleAnalyticsFromPremium() {
|
||||||
|
global $wpdb;
|
||||||
|
if (version_compare($this->settings->get('db_version', '3.38.2'), '3.38.1', '>')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$premium_table_name = $wpdb->prefix . 'mailpoet_premium_newsletter_extra_data';
|
||||||
|
$premium_table_exists = (int)$wpdb->get_var(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT COUNT(1) FROM information_schema.tables WHERE table_schema=%s AND table_name=%s;",
|
||||||
|
$wpdb->dbname,
|
||||||
|
$premium_table_name
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($premium_table_exists) {
|
||||||
|
$query = "
|
||||||
|
UPDATE
|
||||||
|
`%s` as n
|
||||||
|
JOIN %s as ped ON n.id=ped.newsletter_id
|
||||||
|
SET n.ga_campaign = ped.ga_campaign
|
||||||
|
";
|
||||||
|
$wpdb->query(
|
||||||
|
sprintf(
|
||||||
|
$query,
|
||||||
|
Newsletter::$_table,
|
||||||
|
$premium_table_name
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private function detectReferral() {
|
private function detectReferral() {
|
||||||
$this->referralDetector->detect();
|
$this->referralDetector->detect();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user