@@ -114,6 +114,7 @@ public function __construct() {
114114
115115 add_filter ( 'themeisle-sdk/survey/ ' . OPTML_PRODUCT_SLUG , [ $ this , 'get_survey_metadata ' ], 10 , 2 );
116116 add_action ( 'admin_init ' , [ $ this , 'mark_user_with_offload ' ] );
117+ add_filter ( 'themeisle_sdk_blackfriday_data ' , [ $ this , 'add_black_friday_data ' ] );
117118 }
118119
119120 /**
@@ -1591,7 +1592,7 @@ public function get_bf_notices( $user_plan ) {
15911592 $ end ->setTime ( 23 , 59 , 59 );
15921593
15931594 $ promo_code = 'BFCM2525 ' ;
1594-
1595+
15951596 if ( $ has_free_plan ) {
15961597 $ notices ['sidebar ' ] = [
15971598 'title ' => sprintf (
@@ -1603,7 +1604,7 @@ public function get_bf_notices( $user_plan ) {
16031604 'subtitle ' => sprintf (
16041605 /* translators: %1$s is the promo code, %2$s is the discount amount ('25 off') */
16051606 __ ( 'Use code %1$s for an instant %2$s ' , 'optimole-wp ' ),
1606- '<span class="border-b border-0 border-white border-dashed text-promo-orange"> ' . $ promo_code .'</span> ' ,
1607+ '<span class="border-b border-0 border-white border-dashed text-promo-orange"> ' . $ promo_code . '</span> ' ,
16071608 '<span class="text-promo-orange uppercase"> ' . __ ( '25% off ' , 'optimole-wp ' ) . '</span> '
16081609 ),
16091610 'cta_link ' => esc_url_raw ( tsdk_utmify ( tsdk_translate_link ( self ::get_upgrade_base_link () ), 'bfcm25 ' , 'sidebarnotice ' ) ),
@@ -1625,20 +1626,13 @@ public function get_bf_notices( $user_plan ) {
16251626
16261627 if ( $ has_monthly_plan ) {
16271628 $ message = sprintf (
1628- // translators: %1$s is opening span tag, %2$s is closing span tag, %3$s is the discount amount ('15% off')
1629+ // translators: %1$s is opening span tag, %2$s is closing span tag, %3$s is the discount amount ('15% off')
16291630 __ ( '%1$sSwitch to a yearly plan%2$s and get an instant %3$s on your payment. Contact us to reedem your deal ' , 'optimole-wp ' ),
16301631 '<span class=" text-promo-orange"> ' ,
16311632 '</span> ' ,
16321633 '<span class="text-promo-orange uppercase"> ' . __ ( '15% off ' , 'optimole-wp ' ) . '</span> '
16331634 );
1634- $ cta_link = esc_url_raw ( tsdk_utmify ( self ::get_contact_base_link (), 'bfcm25 ' , 'notice ' ) );
1635- $ cta_link = add_query_arg (
1636- [
1637- 'contact_subject ' => rawurlencode ( 'Upgrade to yearly plan - Black Friday offer ' ),
1638- 'contact_website ' => rawurlencode ( home_url () ),
1639- ],
1640- $ cta_link
1641- );
1635+ $ cta_link = $ this ->get_sale_url_for_monthly_plan ();
16421636 $ cta_text = __ ( 'Contact us ' , 'optimole-wp ' );
16431637 }
16441638
@@ -1656,6 +1650,77 @@ public function get_bf_notices( $user_plan ) {
16561650 return $ notices ;
16571651 }
16581652
1653+ /**
1654+ * Set the black friday data.
1655+ *
1656+ * @param array $configs The configuration array for the loaded products.
1657+ * @return array
1658+ */
1659+ public function add_black_friday_data ( $ configs ) {
1660+
1661+ $ service_data = $ this ->settings ->get ( 'service_data ' );
1662+ $ user_plan = isset ( $ service_data ['plan ' ] ) ? $ service_data ['plan ' ] : 'free ' ;
1663+
1664+ $ is_free_plan = 'free ' === $ user_plan ;
1665+ $ is_monthly_plan = strpos ( $ user_plan , '-yearly ' ) === false && ! $ is_free_plan ;
1666+
1667+ if ( ! $ is_free_plan && ! $ is_monthly_plan ) {
1668+ return $ configs ;
1669+ }
1670+
1671+ $ config = $ configs ['default ' ];
1672+
1673+ $ message = sprintf (
1674+ // translators: $1$s is the promo code, $2$s is the discount amount ('25% off')
1675+ __ ( 'Use coupon code %1$s for an instant %2$s on your first billing cycle on Optimole plan. ' , 'optimole-wp ' ),
1676+ '<strong>BFCM2525</strong> ' ,
1677+ '<strong> ' . strtoupper ( __ ( '25% off ' , 'optimole-wp ' ) ) . '</strong> '
1678+ );
1679+ $ title = __ ( 'Optimole Black Friday Private Sale is live! ' , 'optimole-wp ' );
1680+ $ sale_url = esc_url_raw ( tsdk_utmify ( self ::get_upgrade_base_link (), 'bfcm25 ' , 'global_notice ' ) );
1681+
1682+ if ( $ is_monthly_plan ) {
1683+ $ message = sprintf (
1684+ // translators: %1$s is opening strong tag, %2$s is closing strong tag, %3$s is the discount amount ('15% off')
1685+ __ ( '%1$sSwitch to a yearly plan%2$s and get an instant %3$s on your payment. Contact us to reedem your deal ' , 'optimole-wp ' ),
1686+ '<strong> ' ,
1687+ '</strong> ' ,
1688+ '<strong> ' . strtoupper ( __ ( '15% off ' , 'optimole-wp ' ) ) . '</strong> '
1689+ );
1690+ $ sale_url = $ this ->get_sale_url_for_monthly_plan ();
1691+ }
1692+
1693+ $ config ['title ' ] = $ title ;
1694+ $ config ['message ' ] = $ message ;
1695+ $ config ['sale_url ' ] = $ sale_url ;
1696+ $ config ['dismiss ' ] = true ;
1697+
1698+ $ configs ['optimole-wp ' ] = $ config ;
1699+
1700+ return $ configs ;
1701+ }
1702+
1703+ /**
1704+ * Get the sale url for yearly plan.
1705+ *
1706+ * @return string
1707+ */
1708+ private function get_sale_url_for_monthly_plan () {
1709+ $ sale_url = esc_url_raw ( tsdk_utmify ( self ::get_contact_base_link (), 'bfcm25 ' , 'global_notice ' ) );
1710+ $ sale_url = add_query_arg (
1711+ [
1712+ 'contact_subject ' => rawurlencode ( 'Upgrade to yearly plan - Black Friday offer ' ),
1713+ 'contact_website ' => rawurlencode ( home_url () ),
1714+ 'contact_description ' => rawurlencode (
1715+ 'Hi, I saw the Black Friday offer about getting 15% OFF when switching from a monthly to a yearly plan. I would like to redeem this deal. Could you please help to switch my plan? '
1716+ ),
1717+ ],
1718+ $ sale_url
1719+ );
1720+
1721+ return $ sale_url ;
1722+ }
1723+
16591724 /**
16601725 * Get all dashboard strings.
16611726 *
0 commit comments