Skip to content

Commit 2d2f9c0

Browse files
fix
1 parent 9cc8edf commit 2d2f9c0

File tree

9 files changed

+208
-13
lines changed

9 files changed

+208
-13
lines changed

assets/css/code-snippet.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ CSP STYLE
144144
border-radius: 10px;
145145
text-decoration: none;
146146
gap: 5px;
147+
cursor: pointer;
147148
}
148149
.aae-csp-top__tools-btn:hover {
149150
color: rgb(252, 104, 72);

assets/css/code-snippet.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/theme-builder.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@
3333
"#wcf-addons-template-type, #wcf-addons-hf-display-type",
3434
this.displayLocation
3535
);
36+
3637
$(document).on(
3738
"change",
3839
"#wcf-addons--popup--builder-trigger",
3940
this.triggerChange
4041
);
4142

43+
$(document).on(
44+
"change",
45+
"#aae-header-smoother-location",
46+
this.SmootherChange
47+
);
48+
4249
$("#wcf-addons-hf-s-display-type").on("select2:select", function (e) {
4350
// Get the selected data
4451
var selectedItems = $(this).val(); // Get the selected values
@@ -118,6 +125,16 @@
118125
const triggerType = $(this).val();
119126
WCFThemeBuilder.selectorFieldDisplay(triggerType);
120127
},
128+
129+
SmootherChange: function (e) {
130+
e.preventDefault();
131+
const SmoothType = $(this).val();
132+
if(SmoothType === 'no'){
133+
$(".aae-header-smoother-location.yoffset").removeClass("hidden");
134+
}else{
135+
$(".aae-header-smoother-location.yoffset").addClass("hidden");
136+
}
137+
},
121138

122139
selectorFieldDisplay: function (val) {
123140
if (["page_scroll"].includes(val)) {
@@ -235,6 +252,31 @@
235252
}
236253
);
237254

255+
// header
256+
257+
if (
258+
response.responseJSON.data.tmpType &&
259+
response.responseJSON.data.tmpType === "header"
260+
) {
261+
262+
$(".aae-header-smoother-location").removeClass("hidden");
263+
264+
$("#aae-header-smoother-location").val(
265+
response.responseJSON.data.tmpHeaderSmoother
266+
);
267+
268+
$("#aae-header-smoother-yoffset").val(
269+
response.responseJSON.data.tmpHeaderSmootherOffsetY
270+
);
271+
272+
if(response.responseJSON.data.tmpHeaderSmoother !== 'no'){
273+
$(".aae-header-smoother-location.yoffset").addClass("hidden");
274+
}
275+
276+
}else{
277+
$(".aae-header-smoother-location").addClass("hidden");
278+
}
279+
238280
//aae-popup-builder-location
239281
if (
240282
response.responseJSON.data.tmpType &&
@@ -256,9 +298,11 @@
256298
.val(response.responseJSON.data?.tmpEffect)
257299
.trigger("change");
258300
$(".aae-popup-builder-location").removeClass("hidden");
301+
259302
WCFThemeBuilder.selectorFieldDisplay(
260303
response.responseJSON.data?.tmpTrigger
261304
);
305+
262306
} else {
263307
$(".aae-popup-builder-location").addClass("hidden");
264308
}
@@ -351,6 +395,17 @@
351395
: 0;
352396
}
353397

398+
if(tmpType === 'header'){
399+
400+
data["tmpHeaderSmoother"] = $("#aae-header-smoother-location").val()
401+
? $("#aae-header-smoother-location").val()
402+
: "";
403+
404+
data["tmpHeaderSmootherOffsetY"] = $("#aae-header-smoother-yoffset").val()
405+
? $("#aae-header-smoother-yoffset").val()
406+
: "";
407+
}
408+
354409
$.ajax({
355410
url: WCF_Theme_Builder.ajaxurl,
356411
data: data,
@@ -427,6 +482,13 @@
427482
} else {
428483
$(".aae-popup-builder-location").addClass("hidden");
429484
}
485+
486+
if(type === 'header'){
487+
$(".aae-header-smoother-location").removeClass("hidden");
488+
}else{
489+
$(".aae-header-smoother-location").addClass("hidden");
490+
}
491+
430492
},
431493
};
432494

assets/js/theme-builder.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/wcf-template-library.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
remotetemplates.forEach((template, index) => {
6464
if (
6565
(WCF_TEMPLATE_LIBRARY?.config?.wcf_valid &&
66-
WCF_TEMPLATE_LIBRARY?.config?.wcf_valid === true) || template?.is_pro == '0'
66+
WCF_TEMPLATE_LIBRARY?.config?.wcf_valid === true) ||
67+
template?.is_pro == '0'
6768
) {
6869
template["valid"] = "yes";
6970
}

assets/src/js/theme-builder.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@
3333
"#wcf-addons-template-type, #wcf-addons-hf-display-type",
3434
this.displayLocation
3535
);
36+
3637
$(document).on(
3738
"change",
3839
"#wcf-addons--popup--builder-trigger",
3940
this.triggerChange
4041
);
4142

43+
$(document).on(
44+
"change",
45+
"#aae-header-smoother-location",
46+
this.SmootherChange
47+
);
48+
4249
$("#wcf-addons-hf-s-display-type").on("select2:select", function (e) {
4350
// Get the selected data
4451
var selectedItems = $(this).val(); // Get the selected values
@@ -118,6 +125,16 @@
118125
const triggerType = $(this).val();
119126
WCFThemeBuilder.selectorFieldDisplay(triggerType);
120127
},
128+
129+
SmootherChange: function (e) {
130+
e.preventDefault();
131+
const SmoothType = $(this).val();
132+
if(SmoothType === 'no'){
133+
$(".aae-header-smoother-location.yoffset").removeClass("hidden");
134+
}else{
135+
$(".aae-header-smoother-location.yoffset").addClass("hidden");
136+
}
137+
},
121138

122139
selectorFieldDisplay: function (val) {
123140
if (["page_scroll"].includes(val)) {
@@ -235,6 +252,31 @@
235252
}
236253
);
237254

255+
// header
256+
257+
if (
258+
response.responseJSON.data.tmpType &&
259+
response.responseJSON.data.tmpType === "header"
260+
) {
261+
262+
$(".aae-header-smoother-location").removeClass("hidden");
263+
264+
$("#aae-header-smoother-location").val(
265+
response.responseJSON.data.tmpHeaderSmoother
266+
);
267+
268+
$("#aae-header-smoother-yoffset").val(
269+
response.responseJSON.data.tmpHeaderSmootherOffsetY
270+
);
271+
272+
if(response.responseJSON.data.tmpHeaderSmoother !== 'no'){
273+
$(".aae-header-smoother-location.yoffset").addClass("hidden");
274+
}
275+
276+
}else{
277+
$(".aae-header-smoother-location").addClass("hidden");
278+
}
279+
238280
//aae-popup-builder-location
239281
if (
240282
response.responseJSON.data.tmpType &&
@@ -256,9 +298,11 @@
256298
.val(response.responseJSON.data?.tmpEffect)
257299
.trigger("change");
258300
$(".aae-popup-builder-location").removeClass("hidden");
301+
259302
WCFThemeBuilder.selectorFieldDisplay(
260303
response.responseJSON.data?.tmpTrigger
261304
);
305+
262306
} else {
263307
$(".aae-popup-builder-location").addClass("hidden");
264308
}
@@ -351,6 +395,17 @@
351395
: 0;
352396
}
353397

398+
if(tmpType === 'header'){
399+
400+
data["tmpHeaderSmoother"] = $("#aae-header-smoother-location").val()
401+
? $("#aae-header-smoother-location").val()
402+
: "";
403+
404+
data["tmpHeaderSmootherOffsetY"] = $("#aae-header-smoother-yoffset").val()
405+
? $("#aae-header-smoother-yoffset").val()
406+
: "";
407+
}
408+
354409
$.ajax({
355410
url: WCF_Theme_Builder.ajaxurl,
356411
data: data,
@@ -427,6 +482,13 @@
427482
} else {
428483
$(".aae-popup-builder-location").addClass("hidden");
429484
}
485+
486+
if(type === 'header'){
487+
$(".aae-header-smoother-location").removeClass("hidden");
488+
}else{
489+
$(".aae-header-smoother-location").addClass("hidden");
490+
}
491+
430492
},
431493
};
432494

inc/theme-builder/theme-builder.php

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function override_header($name)
121121
if (! $this->has_template('header')) {
122122
return;
123123
}
124-
124+
125125
require WCF_ADDONS_PATH . '/templates/header.php';
126126

127127
$templates = array();
@@ -195,6 +195,7 @@ public function header_builder_content()
195195
$archive_template_id = $this->get_template_id('header');
196196
if ($archive_template_id != '0') {
197197
// PHPCS - should not be escaped.
198+
198199
echo self::render_build_content($archive_template_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
199200
}
200201
}
@@ -283,8 +284,18 @@ private function get_template_loader_default_file()
283284
public function has_template($tmpType = '')
284285
{
285286
$template_ID = self::get_current_post_by_condition($tmpType);
286-
287+
287288
if ($template_ID) {
289+
if($tmpType == 'header'){
290+
$GLOBALS['aae_header_smoother'] = get_post_meta( $template_ID, 'aae_header_smoother', true );
291+
$offsetY = get_post_meta( $template_ID, 'aae_header_smoother_offsety', true );
292+
$offsetY = preg_replace( '/[^0-9.\-]/', '', $offsetY );
293+
if($offsetY && is_numeric($offsetY)){
294+
$GLOBALS['aae_header_smoother_offsetY'] = $offsetY;
295+
}
296+
297+
}
298+
288299
return $template_ID;
289300
}
290301

@@ -501,20 +512,23 @@ public function get_current_post_by_condition($tmpType = '')
501512

502513
return $templates['post-singulars'];
503514
}
515+
504516
// if template type single ignore post type page
505-
if (('page' === get_post_type() || self::CPTTYPE === get_post_type()) && 'single' === $tmpType) {
517+
if ((('page' === get_post_type() && !is_front_page() ) || ( self::CPTTYPE === get_post_type() && !is_front_page() )) && 'single' === $tmpType) {
506518
return false;
507519
}
508-
520+
509521
// check for custom post type singular
510522
$custom_single = get_post_type() . '-singular';
511523

512524
if (array_key_exists($custom_single, $templates)) {
525+
513526
return $templates[$custom_single];
514527
}
515528

516529
// all singular
517-
if (array_key_exists('singulars', $templates)) {
530+
if (array_key_exists('singulars', $templates) && !is_front_page()) {
531+
518532
return $templates['singulars'];
519533
}
520534
}
@@ -1439,6 +1453,23 @@ class="bi bi-x-lg" viewBox="0 0 16 16"><path
14391453
<option value="zoomBounce"><?php echo esc_html__('Zoom + Bounce', 'animation-addons-for-elementor'); ?></option>
14401454
<option value="fadeSlideup"><?php echo esc_html__('Fade + Slide Up', 'animation-addons-for-elementor'); ?></option>
14411455
</select>
1456+
</div>
1457+
<!-- Header Smoother -->
1458+
<div class="wcf-addons-template-edit-field aae-header-smoother-location hidden">
1459+
<label class="wcf-addons-template-edit-label"><?php echo esc_html__('Smoother?', 'animation-addons-for-elementor'); ?></label>
1460+
<select class="wcf-addons-template-edit-input" name="aae-header-smoother-location"
1461+
id="aae-header-smoother-location">
1462+
<option value=""><?php echo esc_html__('Default', 'animation-addons-for-elementor'); ?></option>
1463+
<option value="yes"><?php echo esc_html__('Yes', 'animation-addons-for-elementor'); ?></option>
1464+
<option value="no"><?php echo esc_html__('No', 'animation-addons-for-elementor'); ?></option>
1465+
</select>
1466+
</div>
1467+
1468+
<div class="wcf-addons-template-edit-field aae-header-smoother-location yoffset hidden">
1469+
<label class="wcf-addons-template-edit-label"><?php echo esc_html__('OffsetY(px)', 'animation-addons-for-elementor'); ?></label>
1470+
<input class="wcf-addons-template-edit-input" id="aae-header-smoother-yoffset" type="text"
1471+
name="aae-header-smoother-yoffset"
1472+
placeholder="120">
14421473
</div>
14431474

14441475
</div>
@@ -1501,6 +1532,8 @@ public function save_template_request()
15011532
$popupEffect = ! empty($_POST['tmpEffect']) ? sanitize_text_field(wp_unslash($_POST['tmpEffect'])) : 'flip';
15021533
$selector = ! empty($_POST['tmpSelector']) ? sanitize_text_field(wp_unslash($_POST['tmpSelector'])) : '';
15031534
$scrollPostion = ! empty($_POST['tmpScrollPostion']) ? sanitize_text_field(wp_unslash($_POST['tmpScrollPostion'])) : 0;
1535+
$headerSmoother = ! empty($_POST['tmpHeaderSmoother']) ? sanitize_text_field(wp_unslash($_POST['tmpHeaderSmoother'])) : '';
1536+
$headerSmootheroffset = ! empty($_POST['tmpHeaderSmootherOffsetY']) ? sanitize_text_field(wp_unslash($_POST['tmpHeaderSmootherOffsetY'])) : '';
15041537

15051538
$data = array(
15061539
'title' => $title,
@@ -1512,7 +1545,9 @@ public function save_template_request()
15121545
'tmpTrigger' => $popuptrigger,
15131546
'tmpSelector' => $selector,
15141547
'tmpScrollPostion' => $scrollPostion,
1515-
'tmpEffect' => $popupEffect
1548+
'tmpEffect' => $popupEffect,
1549+
'tmpHeaderSmoother' => $headerSmoother,
1550+
'tmpHeaderSmootherOffsetY' => $headerSmootheroffset
15161551
);
15171552

15181553
if ($tmpid) {
@@ -1563,6 +1598,8 @@ public function get_post_By_id()
15631598
$popupEffect = ! empty(get_post_meta($tmpid, 'effect', true)) ? get_post_meta($tmpid, 'effect', true) : 'flip';
15641599
$popup_selector = ! empty(get_post_meta($tmpid, 'popup_selector', true)) ? get_post_meta($tmpid, 'popup_selector', true) : '';
15651600
$scrollPostion = ! empty(get_post_meta($tmpid, 'scrollPostion', true)) ? get_post_meta($tmpid, 'scrollPostion', true) : '';
1601+
$aae_header_smoother = ! empty(get_post_meta($tmpid, 'aae_header_smoother', true)) ? get_post_meta($tmpid, 'aae_header_smoother', true) : '';
1602+
$header_smootheroffsety = ! empty(get_post_meta($tmpid, 'aae_header_smoother_offsety', true)) ? get_post_meta($tmpid, 'aae_header_smoother_offsety', true) : '';
15661603
$spLocations = array();
15671604

15681605
if (! empty($specificsDisplay)) {
@@ -1581,7 +1618,9 @@ public function get_post_By_id()
15811618
'tmpTrigger' => $popupTrigger,
15821619
'tmpSelector' => $popup_selector,
15831620
'tmpEffect' => $popupEffect,
1584-
'tmpScrollPostion' => $scrollPostion
1621+
'tmpScrollPostion' => $scrollPostion,
1622+
'tmpHeaderSmoother' => $aae_header_smoother,
1623+
'tmpHeaderSmootherOffsetY' => $header_smootheroffsety,
15851624
);
15861625
wp_send_json_success($data);
15871626
} else {
@@ -1743,6 +1782,9 @@ public function insert($data)
17431782
// specific page and post template header footer
17441783
if ('header' === $data['tmptype'] || 'footer' === $data['tmptype']) {
17451784
update_post_meta($new_post_id, self::CPT_META . '_splocation', $data['tmpSpLocation']);
1785+
update_post_meta($new_post_id, 'aae_header_smoother', $data['tmpHeaderSmoother']);
1786+
update_post_meta($new_post_id, 'aae_header_smoother_offsety', $data['tmpHeaderSmootherOffsetY']);
1787+
17461788
}
17471789

17481790
if ('archive' === $data['tmptype'] && 'specifics_cat' === $data['tmplocation']) {
@@ -1795,6 +1837,8 @@ public function update($data)
17951837
// specific page and post template header footer
17961838
if ('header' === $data['tmptype'] || 'footer' === $data['tmptype']) {
17971839
update_post_meta($data['id'], self::CPT_META . '_splocation', $data['tmpSpLocation']);
1840+
update_post_meta($data['id'], 'aae_header_smoother', $data['tmpHeaderSmoother']);
1841+
update_post_meta($data['id'], 'aae_header_smoother_offsety', $data['tmpHeaderSmootherOffsetY']);
17981842
} else {
17991843
delete_post_meta($data['id'], self::CPT_META . '_splocation');
18001844
}

0 commit comments

Comments
 (0)