Skip to content

refactor: use the new black friday hooks #4407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions assets/apps/components/src/Style/_responsive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ $devicemap : 'tablet', 'mobile', 'desktop';
}
}
}

#tsdk_banner:has(.themeisle-sale) {
margin: 0 auto;
padding: 0 1.5rem;
width: 100%;
max-width: 1535px;

.notice.themeisle-sale {
margin: 0;
}
}

16 changes: 4 additions & 12 deletions assets/apps/customizer-controls/src/@types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
type EventResponse = {
error?: string;
success?: boolean;
response?: any;

Check warning on line 122 in assets/apps/customizer-controls/src/@types/utils.d.ts

View workflow job for this annotation

GitHub Actions / npm (16.x)

Unexpected any. Specify a different type
};

type EventOptions = {
Expand Down Expand Up @@ -160,18 +160,10 @@
nonce: string;
hideConditionalHeaderSelector: boolean;
dashUpdatesMessage: string;
deal?: {
active?: boolean;
dealSlug?: string;
urgencyText?: string;
remaningTime?: string;
bannerUrl?: string;
customizerBannerUrl?: string;
bannerStoreUrl?: string;
linkGlobal?: string;
customizerBannerStoreUrl?: string;
customizerBannerAlt?: string;
bannerAlt?: string;
blackFriday?: {
saleUrl: string;
bannerSrc: string;
message: string;
};
};
NeveProReactCustomize: undefined | StringObjectKeys;
Expand Down
20 changes: 5 additions & 15 deletions assets/apps/customizer-controls/src/builder-upsell/Upsells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,21 @@ const Upsells: React.FC<Props> = ({ control }) => {
const { title, url } = params;

if (
window?.NeveReactCustomize?.deal?.active &&
window?.NeveReactCustomize?.deal?.customizerBannerStoreUrl &&
window?.NeveReactCustomize?.deal?.customizerBannerUrl
window?.NeveReactCustomize?.blackFriday?.saleUrl &&
window?.NeveReactCustomize?.blackFriday?.bannerSrc
) {
return (
<div className="upsell-inner">
<a
href={
window?.NeveReactCustomize?.deal
?.customizerBannerStoreUrl
}
href={window?.NeveReactCustomize?.blackFriday?.saleUrl}
target="_blank"
rel="external noreferrer noopener"
style={{ width: '100%', lineHeight: '0' }}
>
<img
src={
window?.NeveReactCustomize?.deal
?.customizerBannerUrl
}
alt={
window?.NeveReactCustomize?.deal
?.customizerBannerAlt
}
src={window?.NeveReactCustomize?.blackFriday?.bannerSrc}
style={{ width: '100%' }}
alt={window?.NeveReactCustomize?.blackFriday?.message}
/>
</a>
</div>
Expand Down
3 changes: 2 additions & 1 deletion assets/apps/dashboard/src/Components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const App = () => {
fetchOptions().then((r) => {
setSettings(r);
setLoading(false);
window.tsdk_reposition_notice();
});
}, []);

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

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

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

Expand Down
33 changes: 0 additions & 33 deletions assets/apps/dashboard/src/Components/Deal.js

This file was deleted.

2 changes: 1 addition & 1 deletion assets/apps/dashboard/src/scss/_general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ svg.is-loading, button.is-loading .dashicon {
aspect-ratio: 16/8;
}
}
}
}
43 changes: 0 additions & 43 deletions assets/apps/dashboard/src/scss/content/_start.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,46 +48,3 @@
}
}
}

.nv-deal {
margin-bottom: 10px;
display: flex;

a {
position: relative;
width: 100%;
}

img {
width: 100%;
}

.nv-urgency {
position: absolute;

top: 10%;
left: 2.7%;

color: #FFF;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", sans-serif;
font-size: 14px;
font-style: normal;
font-weight: 700;
line-height: normal;
letter-spacing: 0.3px;
text-transform: uppercase;
}
}

@media(max-width: 480px) {
.nv-deal .nv-urgency {
font-size: 7px;
}
}

@media (min-width: 481px) and (max-width: 1024px) {
.nv-deal .nv-urgency {
font-size: 10px;
}
}

Binary file removed assets/img/dashboard/black-friday-banner.png
Binary file not shown.
59 changes: 55 additions & 4 deletions inc/admin/dashboard/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Neve\Admin\Dashboard;

use Neve\Core\Limited_Offers;
use Neve\Core\Settings\Config;
use Neve\Core\Theme_Info;
use Neve\Core\Tracker;
Expand Down Expand Up @@ -101,6 +100,8 @@ function () use ( $filtered_name ) {
];
}
);

add_filter( 'themeisle_sdk_blackfriday_data', array( $this, 'add_black_friday_data' ) );
}

/**
Expand Down Expand Up @@ -295,8 +296,6 @@ public function enqueue() {
*/
private function get_localization() {

$offer = new Limited_Offers();

$old_about_config = apply_filters( 'ti_about_config_filter', [ 'useful_plugins' => true ] );
$theme_name = apply_filters( 'ti_wl_theme_name', $this->theme_args['name'] );
$plugin_name = apply_filters( 'ti_wl_plugin_name', 'Neve Pro' );
Expand Down Expand Up @@ -363,7 +362,6 @@ private function get_localization() {
'getPluginStateBaseURL' => esc_url( rest_url( '/nv/v1/dashboard/plugin-state/' ) ),
'canInstallPlugins' => current_user_can( 'install_plugins' ),
'canActivatePlugins' => current_user_can( 'activate_plugins' ),
'deal' => $offer->get_localized_data(),
'rootUrl' => get_site_url(),
];

Expand Down Expand Up @@ -1125,4 +1123,57 @@ function( $data, $page_slug ) use ( $dash_data ) {
2
);
}

/**
* Get the Black Friday config settings.
*
* @param array $default Optional. The default values.
*
* @return array The data.
*/
public static function get_black_friday_data( $default = array() ) {
$config = $default;

// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
$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' );
$product_label = __( 'Neve', 'neve' );
$discount = '70%';

$plan = apply_filters( 'product_neve_license_plan', 0 );
$is_pro = 0 < $plan;

if ( $is_pro ) {
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
$message_template = __( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early.', 'neve' );
$product_label = __( 'Neve Pro', 'neve' );
$discount = '30%';
}

$product_label = sprintf( '<strong>%s</strong>', $product_label );
$url_params = array(
'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
'lkey' => apply_filters( 'product_neve_license_key', false ),
);

$config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label );
$config['sale_url'] = add_query_arg(
$url_params,
tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/neve-bf', 'bfcm', 'neve' ) )
);

return $config;
}

/**
* Add the Black Friday data.
*
* @param array $configs An array of configurations.
*
* @return array The configurations.
*/
public function add_black_friday_data( $configs ) {
$configs['neve'] = self::get_black_friday_data( $configs['default'] );

return $configs;
}
}
Loading
Loading