Skip to content

Commit

Permalink
refactor: extend new upsell features list upsell
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Jan 23, 2025
1 parent dde936a commit 1fdf4e3
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 191 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
ul[id^="sub-accordion-panel-hfg_"] {
.control-subsection {
display: none !important;
display: none !important;
}

.control-subsection:has(.nv-upsell-feat-container) {
display: block !important;
}

li[id*="accordion-section-hfg_"] {
display: block !important;
display: block !important;
}

#accordion-section-neve_header_presets {
margin-top: 20px;
margin-top: 20px;
}
}
1 change: 0 additions & 1 deletion assets/customizer/css/_generic.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
}

.nv-upsell-feat-container {
padding: 16px;
font-family: sans-serif;
display: flex;
flex-direction: column;
Expand Down
9 changes: 9 additions & 0 deletions inc/customizer/controls/simple_upsell.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

namespace Neve\Customizer\Controls;

use Neve\Customizer\Traits\Features_Upsell;

/**
* Simple Upsell Control.
*
* @since 2.8.3
* @access public
*/
class Simple_Upsell extends \WP_Customize_Control {
use Features_Upsell;

/**
* The type of customize control being rendered.
Expand Down Expand Up @@ -69,6 +72,12 @@ class Simple_Upsell extends \WP_Customize_Control {
* @return void
*/
public function render_content() {

if ( ! empty( $this->features_list ) ) {
$this->render_features_body();
return;
}

$base_class = 'nv-simple-upsell';
$class = ( ! empty( $this->class ) ) ? $base_class . ' ' . $this->class : $base_class;
$button_class = ( ! empty( $this->use_primary ) ) ? 'button-primary' : 'button-secondary';
Expand Down
34 changes: 21 additions & 13 deletions inc/customizer/controls/simple_upsell_section.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@

namespace Neve\Customizer\Controls;

use Neve\Customizer\Traits\Features_Upsell;

/**
* Customizer section.
*
* @since 2.8.3
* @see WP_Customize_Section
*/
class Simple_Upsell_Section extends \WP_Customize_Section {
use Features_Upsell;

/**
* Type of this section.
*
Expand Down Expand Up @@ -55,12 +59,12 @@ class Simple_Upsell_Section extends \WP_Customize_Section {
* @return array The array to be exported to the client as JSON.
*/
public function json() {
$json = parent::json();
$json = array_merge( parent::json(), $this->to_json_features() );
$json['button_text'] = $this->button_text;
$json['link'] = $this->link;
$json['text'] = $this->text;
$json['screen_reader'] = __( '(opens in a new tab)', 'neve' );

return $json;
}

Expand All @@ -70,17 +74,21 @@ public function json() {
protected function render_template() {
?>
<li id="accordion-section-{{ data.id }}" class="control-section-{{ data.type }}">
<div class="nv-simple-upsell">
<# if( data.text ) { #>
<p>{{data.text}}</p>
<# } #>
<# if( data.link && data.button_text ) { #>
<a rel="external noreferrer noopener" target="_blank" href="{{data.link}}" class='button button-secondary'>
{{data.button_text}}
<span class="components-visually-hidden">{{data.screen_reader}}</span>
</a>
<# } #>
</div>
<# if ( data.features_list ) { #>
<?php $this->render_features_body_template(); ?>
<# } else { #>
<div class="nv-simple-upsell">
<# if( data.text ) { #>
<p>{{data.text}}</p>
<# } #>
<# if( data.link && data.button_text ) { #>
<a rel="external noreferrer noopener" target="_blank" href="{{data.link}}" class='button button-secondary'>
{{data.button_text}}
<span class="components-visually-hidden">{{data.screen_reader}}</span>
</a>
<# } #>
</div>
<# } #>
</li>
<?php
}
Expand Down
100 changes: 0 additions & 100 deletions inc/customizer/controls/upsells/features_upsell_section.php

This file was deleted.

Loading

0 comments on commit 1fdf4e3

Please sign in to comment.