PluginProbe
WP Ultimate Post Grid / 3.0.0
WP Ultimate Post Grid v3.0.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
← All changes | includes/admin/class-wpupg-marketing.php +19 -61 4.1.1 → 3.0.0 View file →
@@ -18,9 +18,11 @@
18 18 * @author Brecht Vandersmissen <[email protected]>
19 19 */
20 20 class WPUPG_Marketing {
21 21
22 - private static $campaign = false;
22 + private static $marketing_campaign = 'birthday-2020';
23 + private static $marketing_start;
24 + private static $marketing_end;
23 25
24 26 /**
25 27 * Register actions and filters.
26 28 *
@@ -26,62 +28,13 @@
26 28 *
27 29 * @since 3.1.0
28 30 */
29 31 public static function init() {
30 - $campaigns = array(
31 - 'black-friday-2025' => array(
32 - 'start' => new DateTime( '2025-11-24 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
33 - 'end' => new DateTime( '2025-12-02 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
34 - 'notice_title' => 'Black Friday & Cyber Monday Deal',
35 - 'notice_text' => 'Get a 30% discount right now!',
36 - 'page_title' => 'Black Friday Discount!',
37 - 'page_text' => 'Good news: we\'re having a Black Friday & Cyber Monday sale and you can get a <strong>30% discount on any of our plugins</strong>.',
38 - 'url' => 'https://bootstrapped.ventures/black-friday/',
39 - ),
40 - 'birthday-2026' => array(
41 - 'start' => new DateTime( '2026-01-24 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
42 - 'end' => new DateTime( '2026-01-31 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
43 - 'notice_title' => 'Celebrating my birthday',
44 - 'notice_text' => 'Get a 30% discount right now!',
45 - 'page_title' => 'Birthday Discount!',
46 - 'page_text' => 'Good news: I\'m celebrating my birthday with a <strong>30% discount on any of our plugins</strong>.',
47 - 'url' => 'https://bootstrapped.ventures/birthday-discount/',
48 - ),
49 - 'black-friday-2026' => array(
50 - 'start' => new DateTime( '2026-11-23 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
51 - 'end' => new DateTime( '2026-12-01 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
52 - 'notice_title' => 'Black Friday & Cyber Monday Deal',
53 - 'notice_text' => 'Get a 30% discount right now!',
54 - 'page_title' => 'Black Friday Discount!',
55 - 'page_text' => 'Good news: we\'re having a Black Friday & Cyber Monday sale and you can get a <strong>30% discount on any of our plugins</strong>.',
56 - 'url' => 'https://bootstrapped.ventures/black-friday/',
57 - ),
58 - 'birthday-2027' => array(
59 - 'start' => new DateTime( '2027-01-24 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
60 - 'end' => new DateTime( '2027-01-31 10:00:00', new DateTimeZone( 'Europe/Brussels' ) ),
61 - 'notice_title' => 'Celebrating my birthday',
62 - 'notice_text' => 'Get a 30% discount right now!',
63 - 'page_title' => 'Birthday Discount!',
64 - 'page_text' => 'Good news: I\'m celebrating my birthday with a <strong>30% discount on any of our plugins</strong>.',
65 - 'url' => 'https://bootstrapped.ventures/birthday-discount/',
66 - ),
67 - );
68 -
69 32 $now = new DateTime();
33 + self::$marketing_start = new DateTime( '2020-01-24 10:00:00', new DateTimeZone( 'Europe/Brussels' ) );
34 + self::$marketing_end = new DateTime( '2020-01-31 10:00:00', new DateTimeZone( 'Europe/Brussels' ) );
70 35
71 - foreach ( $campaigns as $id => $campaign ) {
72 - if ( $campaign['start'] < $now && $now < $campaign['end'] ) {
73 - $campaign['id'] = $id;
74 -
75 - // Add parameters to URL.
76 - $campaign['url'] .= '?utm_source=wpupg&utm_medium=plugin&utm_campaign=' . urlencode( $id );
77 -
78 - self::$campaign = $campaign;
79 - break;
80 - }
81 - }
82 -
83 - if ( false !== self::$campaign ) {
36 + if ( self::$marketing_start < $now && $now < self::$marketing_end ) {
84 37 add_action( 'admin_menu', array( __CLASS__, 'add_submenu_page' ), 99 );
85 38 add_filter( 'wpupg_admin_notices', array( __CLASS__, 'marketing_notice' ) );
86 39 }
87 40 }
@@ -103,14 +56,13 @@
103 56 * @since 3.1.0
104 57 */
105 58 public static function page_template() {
106 59 echo '<div class="wrap">';
107 - echo '<h1>' . self::$campaign['page_title'] . '</h1>';
108 - echo '<p style="font-size: 14px; max-width: 600px;">' . self::$campaign['page_text'] . '</p>';
109 -
60 + echo '<h1>Birthday Discount!</h1>';
61 + echo '<p style="font-size: 14px; max-width: 600px;">Good news: I\'m celebrating my 32nd birthday with a <strong>30% discount on any of our plugins</strong>. Just use this code on the checkout page: <em>BDAY2020</em></p>';
110 62 // Countdown.
111 63 $now = new DateTime();
112 - $interval = $now->diff( self::$campaign['end'] );
64 + $interval = $now->diff( self::$marketing_end );
113 65 echo '<p style="color: darkred; font-size: 14px;"><strong>Don\'t miss out!</strong><br/>Only ';
114 66 printf( _n( '%s day', '%s days', $interval->d, 'wp-ultimate-post-grid' ), number_format_i18n( $interval->d ) );
115 67 echo ' ';
116 68 printf( _n( '%s hour', '%s hours', $interval->h, 'wp-ultimate-post-grid' ), number_format_i18n( $interval->h ) );
@@ -118,9 +70,15 @@
118 70 printf( _n( '%s minute', '%s minutes', $interval->i, 'wp-ultimate-post-grid' ), number_format_i18n( $interval->i ) );
119 71 echo ' left.</p>';
120 72
121 73 // CTA.
122 - echo '<a href="' . esc_url( self::$campaign['url'] ) . '" target="_blank" class="button button-primary" style="font-size: 14px;">Learn more about the sale!</a>';
74 + $params = '?utm_source=wpupg&utm_medium=plugin&utm_campaign=' . urlencode( self::$marketing_campaign );
75 +
76 + if ( WPUPG_Addons::is_active( 'premium' ) ) {
77 + echo '<a href="https://bootstrapped.ventures/' . $params . '" target="_blank" class="button button-primary" style="font-size: 14px;">Check out our Plugins</a>';
78 + } else {
79 + echo '<a href="https://bootstrapped.ventures/wp-ultimate-post-grid/get-the-plugin/' . $params . '" target="_blank" class="button button-primary" style="font-size: 14px;">Get the Premium plugin now</a>';
80 + }
123 81
124 82 echo '</div>';
125 83 }
126 84
@@ -132,11 +90,11 @@
132 90 */
133 91 public static function marketing_notice( $notices ) {
134 92 if ( ! WPUPG_Addons::is_active( 'premium' ) ) {
135 93 $notices[] = array(
136 - 'id' => 'marketing_' . self::$campaign['id'],
137 - 'title' => self::$campaign['notice_title'],
138 - 'text' => '<a href="' . esc_url( self::$campaign['url'] ) . '" target="_blank">' . self::$campaign['notice_text'] . '</a>',
94 + 'id' => 'marketing_' . self::$marketing_campaign,
95 + 'title' => __( 'Celebrating my 32nd birthday', 'wp-ultimate-post-grid' ),
96 + 'text' => '<a href="' . esc_url( admin_url( 'admin.php?page=wpupg_marketing' ) ). '">' . __( 'Get a 30% discount right now!', 'wp-ultimate-post-grid' ) . '</a>',
139 97 );
140 98 }
141 99
142 100 return $notices;