Skip to content

Commit 0a22298

Browse files
Merge pull request #4407 from Codeinwp/refactor/blackfriday-hooks
refactor: use the new black friday hooks
2 parents 7137a0f + f35b162 commit 0a22298

11 files changed

Lines changed: 108 additions & 410 deletions

File tree

assets/apps/components/src/Style/_responsive.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ $devicemap : 'tablet', 'mobile', 'desktop';
4040
}
4141
}
4242
}
43+
44+
#tsdk_banner:has(.themeisle-sale) {
45+
margin: 0 auto;
46+
padding: 0 1.5rem;
47+
width: 100%;
48+
max-width: 1535px;
49+
50+
.notice.themeisle-sale {
51+
margin: 0;
52+
}
53+
}
54+

assets/apps/customizer-controls/src/@types/utils.d.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,10 @@ declare global {
160160
nonce: string;
161161
hideConditionalHeaderSelector: boolean;
162162
dashUpdatesMessage: string;
163-
deal?: {
164-
active?: boolean;
165-
dealSlug?: string;
166-
urgencyText?: string;
167-
remaningTime?: string;
168-
bannerUrl?: string;
169-
customizerBannerUrl?: string;
170-
bannerStoreUrl?: string;
171-
linkGlobal?: string;
172-
customizerBannerStoreUrl?: string;
173-
customizerBannerAlt?: string;
174-
bannerAlt?: string;
163+
blackFriday?: {
164+
saleUrl: string;
165+
bannerSrc: string;
166+
message: string;
175167
};
176168
};
177169
NeveProReactCustomize: undefined | StringObjectKeys;

assets/apps/customizer-controls/src/builder-upsell/Upsells.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,21 @@ const Upsells: React.FC<Props> = ({ control }) => {
1212
const { title, url, cta } = params;
1313

1414
if (
15-
window?.NeveReactCustomize?.deal?.active &&
16-
window?.NeveReactCustomize?.deal?.customizerBannerStoreUrl &&
17-
window?.NeveReactCustomize?.deal?.customizerBannerUrl
15+
window?.NeveReactCustomize?.blackFriday?.saleUrl &&
16+
window?.NeveReactCustomize?.blackFriday?.bannerSrc
1817
) {
1918
return (
2019
<div className="upsell-inner">
2120
<a
22-
href={
23-
window?.NeveReactCustomize?.deal
24-
?.customizerBannerStoreUrl
25-
}
21+
href={window?.NeveReactCustomize?.blackFriday?.saleUrl}
2622
target="_blank"
2723
rel="external noreferrer noopener"
2824
style={{ width: '100%', lineHeight: '0' }}
2925
>
3026
<img
31-
src={
32-
window?.NeveReactCustomize?.deal
33-
?.customizerBannerUrl
34-
}
35-
alt={
36-
window?.NeveReactCustomize?.deal
37-
?.customizerBannerAlt
38-
}
27+
src={window?.NeveReactCustomize?.blackFriday?.bannerSrc}
3928
style={{ width: '100%' }}
29+
alt={window?.NeveReactCustomize?.blackFriday?.message}
4030
/>
4131
</a>
4232
</div>

assets/apps/dashboard/src/Components/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const App = () => {
2828
fetchOptions().then((r) => {
2929
setSettings(r);
3030
setLoading(false);
31+
window.tsdk_reposition_notice();
3132
});
3233
}, []);
3334

@@ -38,9 +39,9 @@ const App = () => {
3839
<div className="antialiased grow flex flex-col gap-6 h-full">
3940
<Header />
4041

41-
{/*<Deal />*/}
4242
{'starter-sites' !== currentTab && <Notifications />}
4343

44+
<div id="tsdk_banner"></div>
4445
<Container className="flex flex-col lg:flex-row gap-6 h-full grow">
4546
<div className="grow">{tabs[currentTab].render(setTab)}</div>
4647

assets/apps/dashboard/src/Components/Deal.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

assets/apps/dashboard/src/scss/_general.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ svg.is-loading, button.is-loading .dashicon {
162162
aspect-ratio: 16/8;
163163
}
164164
}
165-
}
165+
}

assets/apps/dashboard/src/scss/content/_start.scss

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -48,46 +48,3 @@
4848
}
4949
}
5050
}
51-
52-
.nv-deal {
53-
margin-bottom: 10px;
54-
display: flex;
55-
56-
a {
57-
position: relative;
58-
width: 100%;
59-
}
60-
61-
img {
62-
width: 100%;
63-
}
64-
65-
.nv-urgency {
66-
position: absolute;
67-
68-
top: 10%;
69-
left: 2.7%;
70-
71-
color: #FFF;
72-
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", sans-serif;
73-
font-size: 14px;
74-
font-style: normal;
75-
font-weight: 700;
76-
line-height: normal;
77-
letter-spacing: 0.3px;
78-
text-transform: uppercase;
79-
}
80-
}
81-
82-
@media(max-width: 480px) {
83-
.nv-deal .nv-urgency {
84-
font-size: 7px;
85-
}
86-
}
87-
88-
@media (min-width: 481px) and (max-width: 1024px) {
89-
.nv-deal .nv-urgency {
90-
font-size: 10px;
91-
}
92-
}
93-
-27.6 KB
Binary file not shown.

inc/admin/dashboard/main.php

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Neve\Admin\Dashboard;
99

10-
use Neve\Core\Limited_Offers;
1110
use Neve\Core\Settings\Config;
1211
use Neve\Core\Theme_Info;
1312
use Neve\Core\Tracker;
@@ -101,6 +100,8 @@ function () use ( $filtered_name ) {
101100
];
102101
}
103102
);
103+
104+
add_filter( 'themeisle_sdk_blackfriday_data', array( $this, 'add_black_friday_data' ) );
104105
}
105106

106107
/**
@@ -295,8 +296,6 @@ public function enqueue() {
295296
*/
296297
private function get_localization() {
297298

298-
$offer = new Limited_Offers();
299-
300299
$old_about_config = apply_filters( 'ti_about_config_filter', [ 'useful_plugins' => true ] );
301300
$theme_name = apply_filters( 'ti_wl_theme_name', $this->theme_args['name'] );
302301
$plugin_name = apply_filters( 'ti_wl_plugin_name', 'Neve Pro' );
@@ -363,7 +362,6 @@ private function get_localization() {
363362
'getPluginStateBaseURL' => esc_url( rest_url( '/nv/v1/dashboard/plugin-state/' ) ),
364363
'canInstallPlugins' => current_user_can( 'install_plugins' ),
365364
'canActivatePlugins' => current_user_can( 'activate_plugins' ),
366-
'deal' => $offer->get_localized_data(),
367365
'rootUrl' => get_site_url(),
368366
'sparksActive' => defined( 'SPARKS_WC_VERSION' ) ? 'yes' : 'no',
369367
];
@@ -1126,4 +1124,57 @@ function( $data, $page_slug ) use ( $dash_data ) {
11261124
2
11271125
);
11281126
}
1127+
1128+
/**
1129+
* Get the Black Friday config settings.
1130+
*
1131+
* @param array $default Optional. The default values.
1132+
*
1133+
* @return array The data.
1134+
*/
1135+
public static function get_black_friday_data( $default = array() ) {
1136+
$config = $default;
1137+
1138+
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1139+
$message_template = __( 'Our biggest sale of the year: %1$sup to %2$s OFF%3$s on %4$s. Don\'t miss this limited-time offer.', 'neve' );
1140+
$product_label = __( 'Neve', 'neve' );
1141+
$discount = '70%';
1142+
1143+
$plan = apply_filters( 'product_neve_license_plan', 0 );
1144+
$is_pro = 0 < $plan;
1145+
1146+
if ( $is_pro ) {
1147+
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1148+
$message_template = __( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early.', 'neve' );
1149+
$product_label = __( 'Neve Pro', 'neve' );
1150+
$discount = '30%';
1151+
}
1152+
1153+
$product_label = sprintf( '<strong>%s</strong>', $product_label );
1154+
$url_params = array(
1155+
'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
1156+
'lkey' => apply_filters( 'product_neve_license_key', false ),
1157+
);
1158+
1159+
$config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label );
1160+
$config['sale_url'] = add_query_arg(
1161+
$url_params,
1162+
tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/neve-bf', 'bfcm', 'neve' ) )
1163+
);
1164+
1165+
return $config;
1166+
}
1167+
1168+
/**
1169+
* Add the Black Friday data.
1170+
*
1171+
* @param array $configs An array of configurations.
1172+
*
1173+
* @return array The configurations.
1174+
*/
1175+
public function add_black_friday_data( $configs ) {
1176+
$configs['neve'] = self::get_black_friday_data( $configs['default'] );
1177+
1178+
return $configs;
1179+
}
11291180
}

0 commit comments

Comments
 (0)