Skip to content

Commit

Permalink
Merge pull request #4121 from Codeinwp/feat/limited-offers
Browse files Browse the repository at this point in the history
Add BF deal
  • Loading branch information
cristian-ungureanu authored Oct 23, 2023
2 parents 6f1cb8a + cdcae52 commit ca8f87a
Show file tree
Hide file tree
Showing 11 changed files with 474 additions and 0 deletions.
13 changes: 13 additions & 0 deletions assets/apps/customizer-controls/src/@types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ declare global {
nonce: string;
hideConditionalHeaderSelector: boolean;
dashUpdatesMessage: string;
deal?: {
active?: boolean;
dealSlug?: string;
urgencyText?: string;
remaningTime?: string;
bannerUrl?: string;
customizerBannerUrl?: string;
linkDashboard?: string;
linkGlobal?: string;
linkCustomizer?: string;
customizerBannerAlt?: string;
bannerAlt?: string;
};
};
NeveProReactCustomize: undefined | StringObjectKeys;
}
Expand Down
25 changes: 25 additions & 0 deletions assets/apps/customizer-controls/src/builder-upsell/Upsells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ const Upsells: React.FC<Props> = ({ control }) => {
const { params } = control;
const { title, url } = params;

if (window?.NeveReactCustomize?.deal?.active) {
return (
<div className="upsell-inner">
<a
href={window?.NeveReactCustomize?.deal?.linkCustomizer}
target="_blank"
rel="external noreferrer noopener"
style={{ width: '100%', lineHeight: '0' }}
>
<img
src={
window?.NeveReactCustomize?.deal
?.customizerBannerUrl
}
alt={
window?.NeveReactCustomize?.deal
?.customizerBannerAlt
}
style={{ width: '100%' }}
/>
</a>
</div>
);
}

return (
<div className="upsell-inner">
{title && (
Expand Down
2 changes: 2 additions & 0 deletions assets/apps/dashboard/src/Components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { fetchOptions } from '../utils/rest';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { useState, Fragment, useEffect } from '@wordpress/element';
import Deal from './Deal';

const App = ({ setSettings, toast, currentTab, setTab }) => {
const [loading, setLoading] = useState(true);
Expand All @@ -27,6 +28,7 @@ const App = ({ setSettings, toast, currentTab, setTab }) => {
<div className="content-wrap">
<div className="container content">
<div className="main">
<Deal />
{'starter-sites' !== currentTab && <Notifications />}
<TabsContent currentTab={currentTab} setTab={setTab} />
</div>
Expand Down
25 changes: 25 additions & 0 deletions assets/apps/dashboard/src/Components/Deal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* global neveDash */

const Deal = () => {
if (!Boolean(window.neveDash?.deal?.active)) {
return <></>;
}

return (
<div className="nv-deal">
<a
href={neveDash?.deal?.linkDashboard}
target="_blank"
rel="external noreferrer noopener"
>
<img
src={neveDash?.deal?.bannerUrl}
alt={neveDash?.deal?.bannerAlt}
/>
<div className="nv-urgency">{neveDash?.deal?.urgencyText}</div>
</a>
</div>
);
};

export default Deal;
43 changes: 43 additions & 0 deletions assets/apps/dashboard/src/scss/content/_start.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,46 @@
}
}
}

.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 added assets/img/dashboard/black-friday-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions inc/admin/dashboard/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Neve\Admin\Dashboard;

use Neve\Core\Limited_Offers;
use Neve\Core\Theme_Info;
/**
* Class Main
Expand Down Expand Up @@ -315,6 +316,9 @@ public function enqueue() {
* @return array
*/
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 @@ -376,6 +380,7 @@ 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' => ! defined( 'NEVE_PRO_VERSION' ) ? $offer->get_localized_data() : array(),
];

if ( defined( 'NEVE_PRO_PATH' ) ) {
Expand Down
8 changes: 8 additions & 0 deletions inc/core/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ function () {

add_action( 'rest_api_init', [ $this, 'register_rest_routes' ] );
add_filter( 'neve_pro_react_controls_localization', [ $this, 'adapt_conditional_headers' ] );


if ( ! defined( 'NEVE_PRO_VERSION' ) ) {
$offer = new Limited_Offers();
if ( $offer->can_show_dashboard_banner() && $offer->is_active() ) {
$offer->load_dashboard_hooks();
}
}
}

/**
Expand Down
Loading

0 comments on commit ca8f87a

Please sign in to comment.