Skip to content

Commit 31ae175

Browse files
committed
Show existing users to welcome message after update
Signed-off-by: Tareq Hasan <tareq1988@gmail.com>
1 parent 297b04b commit 31ae175

8 files changed

Lines changed: 109 additions & 6 deletions

File tree

assets/images/logo.png

7.23 KB
Loading

conversion-tracking.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function includes() {
134134
require_once WCCT_INCLUDES . '/class-integration-pro-features.php';
135135
require_once WCCT_INCLUDES . '/class-ajax.php';
136136
require_once WCCT_INCLUDES . '/class-admin.php';
137+
require_once WCCT_INCLUDES . '/class-welcome-20.php';
137138
}
138139

139140
/**
@@ -194,6 +195,8 @@ public function init_classes() {
194195
$this->container['admin'] = new WCCT_Admin();
195196
$this->container['manager'] = new WCCT_Integration_Manager();
196197

198+
new WCCT_Welcome_20();
199+
197200
if ( ! class_exists( 'WeDevs_WC_Conversion_Tracking_Pro') ) {
198201
$this->container['pro_feature'] = new WCCT_Pro_Features();
199202
}

includes/class-integration-pro-features.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,18 @@ public function profeature_ad() {
103103

104104
<ul class="premium-feature-list">
105105
<li>Advanced Facebook Events and Tracking</li>
106-
<li>Facebook Product Catalog</li>
107-
<li>Multiple Facebook Pixels</li>
106+
<li>Facebook <strong>Product Catalog</strong></li>
107+
<li><mark><strong>Multiple</strong> Facebook Pixels</mark></li>
108108
<li>Advanced Google Adwords Events</li>
109109
<li>Advanced Twitter Events</li>
110110
<li>Perfect Audience Integration</li>
111111
</ul>
112112

113113
<a href="https://wedevs.com/woocommerce-conversion-tracking/upgrade-to-pro/?utm_source=wp-admin&utm_medium=pro-upgrade&utm_campaign=wcct_upgrade&utm_content=Get_Premium" target="_blank" class="button button-primary"><?php _e( 'Get Premium', 'woocommerce-conversion-tracking' ) ?></a>
114+
115+
<p style="margin-bottom: 0" class="help">
116+
Get <strong>50% Discount</strong> on pro upgrade for a limited time.
117+
</p>
114118
</div>
115119
<?php
116120
}

includes/class-upgrades.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class WCCT_Upgrades {
2222
* @return string
2323
*/
2424
public function get_version() {
25-
return get_option( 'wcct_version' );
25+
return get_option( 'wcct_version', false );
2626
}
2727

2828
/**
@@ -31,13 +31,14 @@ public function get_version() {
3131
* @return boolean
3232
*/
3333
public function needs_update() {
34+
$version = $this->get_version();
3435

3536
// may be it's the first install
36-
if ( ! $this->get_version() ) {
37+
if ( ! $version ) {
3738
return false;
3839
}
3940

40-
if ( version_compare( $this->get_version(), WCCT_VERSION, '<' ) && in_array( WCCT_VERSION, self::$upgrades ) ) {
41+
if ( version_compare( $version, WCCT_VERSION, '<' ) && array_key_exists( WCCT_VERSION, self::$upgrades ) ) {
4142
return true;
4243
}
4344

includes/class-welcome-20.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* The welcome class after install
5+
*
6+
* @since 1.1.0
7+
*/
8+
class WCCT_Welcome_20 {
9+
10+
function __construct() {
11+
add_action( 'admin_init', array( $this, 'redirect_to_page' ), 9999 );
12+
add_action( 'wcct_before_nav', array( $this, 'show_notice' ) );
13+
}
14+
15+
/**
16+
* Redirect to the welcome page once the plugin is installed
17+
*
18+
* @return void
19+
*/
20+
public function redirect_to_page() {
21+
if ( ! get_transient( 'wcct_upgrade_to_20' ) ) {
22+
return;
23+
}
24+
25+
delete_transient( 'wcct_upgrade_to_20' );
26+
27+
// Only do this for single site installs.
28+
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
29+
return;
30+
}
31+
32+
wp_safe_redirect( admin_url( 'admin.php?page=conversion-tracking&notice=welcome' ) );
33+
exit;
34+
}
35+
36+
/**
37+
* Show welcome notice to 2.0
38+
*
39+
* @return void
40+
*/
41+
public function show_notice() {
42+
if ( isset( $_GET['notice'] ) && $_GET['notice'] === 'welcome' ) {
43+
include WCCT_INCLUDES . '/views/welcome-20.php';
44+
}
45+
}
46+
}

includes/upgrades/upgrade-2.0.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ function wcct_upgrade_2_0_change_option_key() {
2020
);
2121

2222
update_option( 'wcct_settings', $change_settings['custom'] );
23+
24+
// redirect transient
25+
set_transient( 'wcct_upgrade_to_20', true, MINUTE_IN_SECONDS );
2326
}
2427

25-
wcct_upgrade_2_0_change_option_key();
28+
wcct_upgrade_2_0_change_option_key();

includes/views/admin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<div class="wrap wcct-admin">
22

3+
<?php do_action( 'wcct_before_nav' ); ?>
4+
35
<?php
46
$this->show_navigation();
57
$tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'integrations';

includes/views/welcome-20.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<div class="wcct-welcome">
2+
<div class="icon-wrap">
3+
<img src="<?php echo WCCT_ASSETS; ?>/images/logo.png" alt="Conversion Tracking Logo">
4+
</div>
5+
6+
<div class="msg-wrap">
7+
<h3>WooCommerce Conversion Tracking just got better</h3>
8+
9+
<p>
10+
Good news, now you can easily track conversions of your WooCommerce store and send data to your favorite ad platforms for improved and precised retargeting campaigns without any coding at all! This makes your Facebook, Twitter, Google Adwords marketing and retargeting easier than ever!
11+
</p>
12+
13+
<p>
14+
<a href="https://wedevs.com/blog/?utm_source=wp-admin&utm_medium=whats_new&utm_campaign=wcct_upgrade_20&utm_content=Whats_New" target="_blank" class="button button-primary">Checkout What's New</a>
15+
<a href="https://wedevs.com/woocommerce-conversion-tracking/upgrade-to-pro/?utm_source=wp-admin&utm_medium=pro-upgrade&utm_campaign=wcct_upgrade&utm_content=Get_Premium" target="_blank" class="button">Upgrate to Pro</a>
16+
</p>
17+
</div>
18+
</div>
19+
20+
<style>
21+
.wcct-welcome {
22+
background: #fff;
23+
padding: 10px 15px;
24+
border: 1px solid #e5e5e5;
25+
box-shadow: 0 1px 1px rgba(0,0,0,.04);
26+
display: flex;
27+
margin-top: 15px;
28+
margin-bottom: 15px;
29+
}
30+
31+
.wcct-welcome .icon-wrap {
32+
width: 100px;
33+
margin-right: 15px;
34+
}
35+
36+
.wcct-welcome .icon-wrap img {
37+
max-width: 100%;
38+
}
39+
40+
.wcct-welcome h3 {
41+
margin-top: 5px;
42+
margin-bottom: 10px;
43+
}
44+
</style>

0 commit comments

Comments
 (0)