Initial commit: Atomaste website

This commit is contained in:
2025-12-10 12:17:30 -05:00
commit 0b9e5d1605
19260 changed files with 5206382 additions and 0 deletions

View File

@@ -0,0 +1,520 @@
/**
* This file adds some LIVE to the Customizer live preview. To leverage
* this, set your custom settings to 'postMessage' and then add your handling
* here. Your javascript should grab settings from customizer controls, and
* then make any necessary changes to the page using jQuery.
*
* @package Astra
* @since x.x.x
*/
function astra_dynamic_build_css( addon, control, css_property, selector, unitSupport = false ) {
var tablet_break_point = AstraPostStrcturesData.tablet_break_point || 768,
mobile_break_point = AstraPostStrcturesData.mobile_break_point || 544,
unitSuffix = unitSupport || '';
wp.customize( control, function( value ) {
value.bind( function( value ) {
if ( value.desktop || value.mobile || value.tablet ) {
// Remove <style> first!
control = control.replace( '[', '-' );
control = control.replace( ']', '' );
jQuery( 'style#' + control + '-dynamic-preview-css' ).remove();
var DeskVal = '',
TabletFontVal = '',
MobileVal = '';
if ( '' != value.desktop ) {
DeskVal = css_property + ': ' + value.desktop;
}
if ( '' != value.tablet ) {
TabletFontVal = css_property + ': ' + value.tablet;
}
if ( '' != value.mobile ) {
MobileVal = css_property + ': ' + value.mobile;
}
// Concat and append new <style>.
jQuery( 'head' ).append(
'<style id="' + control + '-dynamic-preview-css">'
+ selector + ' { ' + DeskVal + unitSuffix + ' }'
+ '@media (max-width: ' + tablet_break_point + 'px) {' + selector + ' { ' + TabletFontVal + unitSuffix + ' } }'
+ '@media (max-width: ' + mobile_break_point + 'px) {' + selector + ' { ' + MobileVal + unitSuffix + ' } }'
+ '</style>'
);
} else {
jQuery( 'style#' + control + '-' + addon ).remove();
}
} );
} );
}
function astra_refresh_customizer( control ) {
wp.customize( control, function( value ) {
value.bind( function( value ) {
wp.customize.preview.send( 'refresh' );
} );
} );
}
( function( $ ) {
var postTypesCount = AstraPostStrcturesData.post_types.length || false,
postTypes = AstraPostStrcturesData.post_types || [],
specialsTypesCount = AstraPostStrcturesData.special_pages.length || false,
specialsTypes = AstraPostStrcturesData.special_pages || [],
tablet_break_point = AstraPostStrcturesData.tablet_break_point || 768,
mobile_break_point = AstraPostStrcturesData.mobile_break_point || 544;
/**
* For single layouts.
*/
for ( var index = 0; index < postTypesCount; index++ ) {
var postType = postTypes[ index ],
layoutType = ( undefined !== wp.customize( 'astra-settings[ast-dynamic-single-' + postType + '-layout]' ) ) ? wp.customize( 'astra-settings[ast-dynamic-single-' + postType + '-layout]' ).get() : 'both';
let exclude_attribute = AstraPostStrcturesData.enabled_related_post ? ':not(.related-entry-header)' : '';
let selector = '';
if( 'layout-2' === layoutType ) {
selector = 'body .ast-single-entry-banner[data-post-type="' + postType + '"]';
} else if( 'layout-1' === layoutType ) {
selector = 'header.entry-header' + exclude_attribute;
} else {
selector = 'body .ast-single-entry-banner[data-post-type="' + postType + '"], header.entry-header';
}
let singleSectionID = '',
bodyPostTypeClass = 'single-' + postType;
if ( 'post' !== postType ) {
if ( 'product' === postType ) {
singleSectionID = 'section-woo-shop-single';
} else if ( 'page' === postType ) {
bodyPostTypeClass = 'page';
singleSectionID = 'section-single-page';
} else if ( 'download' === postType ) {
singleSectionID = 'section-edd-single';
} else {
singleSectionID = 'single-posttype-' . postType;
}
astra_responsive_spacing( 'astra-settings[' + singleSectionID + '-padding]', 'body.' + bodyPostTypeClass + ' .site .site-content #primary .ast-article-single', 'padding', ['top', 'right', 'bottom', 'left' ] );
astra_responsive_spacing( 'astra-settings[' + singleSectionID + '-margin]', 'body.' + bodyPostTypeClass + ' .site .site-content #primary', 'margin', ['top', 'right', 'bottom', 'left' ] );
}
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-meta-date-type]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-date-format]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-taxonomy]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-taxonomy-1]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-taxonomy-2]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-taxonomy-style]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-taxonomy-1-style]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-taxonomy-2-style]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-author-avatar]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-structural-taxonomy]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-structural-taxonomy-style]' );
wp.customize( 'astra-settings[ast-dynamic-single-' + postType + '-author-avatar-size]', function( value ) {
value.bind( function( size ) {
var dynamicStyle = '';
dynamicStyle += '.site .ast-author-avatar img {';
dynamicStyle += 'width: ' + size + 'px;';
dynamicStyle += 'height: ' + size + 'px;';
dynamicStyle += '} ';
astra_add_dynamic_css( 'ast-dynamic-single-' + postType + '-author-avatar-size', dynamicStyle );
} );
} );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-position-layout-1]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-position-layout-2]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-width-type]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-ratio-type]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-ratio-pre-scale]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-custom-scale-width]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-custom-scale-height]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-article-featured-image-size]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-remove-featured-padding]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-metadata-separator]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-author-prefix-label]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-featured-as-background]' );
astra_refresh_customizer( 'astra-settings[ast-dynamic-single-' + postType + '-banner-featured-overlay]' );
astra_dynamic_build_css(
'ast-dynamic-single-' + postType + '-horizontal-alignment',
'astra-settings[ast-dynamic-single-' + postType + '-horizontal-alignment]',
'text-align',
selector
);
astra_dynamic_build_css(
'ast-dynamic-single-' + postType + '-banner-height',
'astra-settings[ast-dynamic-single-' + postType + '-banner-height]',
'min-height',
selector,
'px'
);
astra_apply_responsive_background_css( 'astra-settings[ast-dynamic-single-' + postType + '-banner-background]', ' body .ast-single-entry-banner[data-post-type="' + postType + '"]', 'desktop' );
astra_apply_responsive_background_css( 'astra-settings[ast-dynamic-single-' + postType + '-banner-background]', ' body .ast-single-entry-banner[data-post-type="' + postType + '"]', 'tablet' );
astra_apply_responsive_background_css( 'astra-settings[ast-dynamic-single-' + postType + '-banner-background]', ' body .ast-single-entry-banner[data-post-type="' + postType + '"]', 'mobile' );
astra_css(
'astra-settings[ast-dynamic-single-' + postType + '-vertical-alignment]',
'justify-content',
'body .ast-single-entry-banner[data-post-type="' + postType + '"]'
);
astra_css(
'astra-settings[ast-dynamic-single-' + postType + '-banner-custom-width]',
'max-width',
'body .ast-single-entry-banner[data-post-type="' + postType + '"][data-banner-width-type="custom"]',
'px'
);
astra_css(
'astra-settings[ast-dynamic-single-' + postType + '-elements-gap]',
'margin-bottom',
'header.entry-header > *:not(:last-child), body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container > *:not(:last-child), header.entry-header .read-more, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .read-more',
'px'
);
astra_css(
'astra-settings[ast-dynamic-single-' + postType + '-banner-text-color]',
'color',
'header.entry-header *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container *',
);
astra_css(
'astra-settings[ast-dynamic-single-' + postType + '-banner-title-color]',
'color',
'header.entry-header .entry-title, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-title',
);
astra_css(
'astra-settings[ast-dynamic-single-' + postType + '-banner-link-color]',
'color',
'body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container a, header.entry-header a, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container a *, header.entry-header a *'
);
astra_css(
'astra-settings[ast-dynamic-single-' + postType + '-banner-link-hover-color]',
'color',
'body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container a:hover, header.entry-header a:hover, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container a:hover *, header.entry-header a:hover *'
);
astra_responsive_spacing( 'astra-settings[ast-dynamic-single-' + postType + '-banner-padding]','body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container', 'padding', ['top', 'right', 'bottom', 'left' ] );
astra_responsive_spacing( 'astra-settings[ast-dynamic-single-' + postType + '-banner-margin]','body .ast-single-entry-banner[data-post-type="' + postType + '"]', 'margin', ['top', 'right', 'bottom', 'left' ] );
// Banner - Title.
astra_generate_outside_font_family_css( 'astra-settings[ast-dynamic-single-' + postType + '-title-font-family]', ' header.entry-header .entry-title, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-title' );
astra_generate_font_weight_css( 'astra-settings[ast-dynamic-single-' + postType + '-title-font-family]', 'astra-settings[ast-dynamic-single-' + postType + '-title-font-weight]', 'font-weight', ' header.entry-header .entry-title, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-title' );
astra_css( 'astra-settings[ast-dynamic-single-' + postType + '-title-font-weight]', 'font-weight', ' header.entry-header .entry-title, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-title' );
astra_responsive_font_size( 'astra-settings[ast-dynamic-single-' + postType + '-title-font-size]', ' header.entry-header .entry-title, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-title' );
astra_font_extras_css( 'ast-dynamic-single-' + postType + '-title-font-extras', ' header.entry-header .entry-title, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-title' );
// Banner - Text.
astra_generate_outside_font_family_css( 'astra-settings[ast-dynamic-single-' + postType + '-text-font-family]', ' header.entry-header *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container *' );
astra_generate_font_weight_css( 'astra-settings[ast-dynamic-single-' + postType + '-text-font-family]', 'astra-settings[ast-dynamic-single-' + postType + '-text-font-weight]', 'font-weight', ' header.entry-header *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container *' );
astra_css( 'astra-settings[ast-dynamic-single-' + postType + '-text-font-weight]', 'font-weight', ' header.entry-header *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container *' );
astra_responsive_font_size( 'astra-settings[ast-dynamic-single-' + postType + '-text-font-size]', ' header.entry-header *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container *' );
astra_font_extras_css( 'ast-dynamic-single-' + postType + '-text-font-extras', ' header.entry-header *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container *' );
// Banner - Meta.
astra_generate_outside_font_family_css( 'astra-settings[ast-dynamic-single-' + postType + '-meta-font-family]', ' header.entry-header .entry-meta, header.entry-header .entry-meta *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta *' );
astra_generate_font_weight_css( 'astra-settings[ast-dynamic-single-' + postType + '-meta-font-family]', 'astra-settings[ast-dynamic-single-' + postType + '-meta-font-weight]', 'font-weight', ' header.entry-header .entry-meta, header.entry-header .entry-meta *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta *' );
astra_css( 'astra-settings[ast-dynamic-single-' + postType + '-meta-font-weight]', 'font-weight', ' header.entry-header .entry-meta, header.entry-header .entry-meta *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta *' );
astra_responsive_font_size( 'astra-settings[ast-dynamic-single-' + postType + '-meta-font-size]', ' header.entry-header .entry-meta, header.entry-header .entry-meta *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta *' );
astra_font_extras_css( 'ast-dynamic-single-' + postType + '-meta-font-extras', ' header.entry-header .entry-meta, header.entry-header .entry-meta *, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta, body .ast-single-entry-banner[data-post-type="' + postType + '"] .ast-container .entry-meta *' );
}
/**
* For archive layouts.
*/
for ( var index = 0; index < postTypesCount; index++ ) {
var postType = postTypes[ index ],
layoutType = ( undefined !== wp.customize( 'astra-settings[ast-dynamic-archive-' + postType + '-layout]' ) ) ? wp.customize( 'astra-settings[ast-dynamic-archive-' + postType + '-layout]' ).get() : 'both',
layout1BodySelector = 'sc_product' === postType ? 'body.page' : 'body.archive';
if( 'layout-2' === layoutType ) {
var selector = 'body .ast-archive-entry-banner[data-post-type="' + postType + '"]';
} else if( 'layout-1' === layoutType ) {
var selector = '' + layout1BodySelector + ' .ast-archive-description';
} else {
var selector = 'body .ast-archive-entry-banner[data-post-type="' + postType + '"], ' + layout1BodySelector + ' .ast-archive-description';
}
astra_refresh_customizer(
'astra-settings[ast-dynamic-archive-' + postType + '-custom-title]'
);
astra_refresh_customizer(
'astra-settings[ast-dynamic-archive-' + postType + '-custom-description]'
);
astra_dynamic_build_css(
'ast-dynamic-archive-' + postType + '-horizontal-alignment',
'astra-settings[ast-dynamic-archive-' + postType + '-horizontal-alignment]',
'text-align',
selector
);
astra_dynamic_build_css(
'ast-dynamic-archive-' + postType + '-banner-height',
'astra-settings[ast-dynamic-archive-' + postType + '-banner-height]',
'min-height',
selector,
'px'
);
wp.customize( 'astra-settings[ast-dynamic-archive-' + postType + 'banner-width-type]', function( value ) {
value.bind( function( type ) {
if ( 'custom' === type ) {
jQuery('body .ast-archive-entry-banner[data-post-type="' + postType + '"]').attr( 'data-banner-width-type', 'custom' );
var customWidthSize = wp.customize( 'astra-settings[ast-dynamic-archive-' + postType + 'banner-custom-width]' ).get(),
dynamicStyle = '';
dynamicStyle += 'body .ast-archive-entry-banner[data-post-type="' + postType + '"][data-banner-width-type="custom"] {';
dynamicStyle += 'max-width: ' + customWidthSize + 'px;';
dynamicStyle += '} ';
astra_add_dynamic_css( 'ast-dynamic-archive-' + postType + '-banner-width-type', dynamicStyle );
} else {
jQuery('body .ast-archive-entry-banner[data-post-type="' + postType + '"]').attr( 'data-banner-width-type', 'full' );
}
} );
} );
wp.customize( 'astra-settings[ast-dynamic-archive-' + postType + '-banner-height]', function( value ) {
value.bind( function( size ) {
if( size.desktop != '' || size.tablet != '' || size.mobile != '' ) {
var dynamicStyle = '';
dynamicStyle += 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] {';
dynamicStyle += 'min-height: ' + size.desktop + 'px;';
dynamicStyle += '} ';
dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) {';
dynamicStyle += 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] {';
dynamicStyle += 'min-height: ' + size.tablet + 'px;';
dynamicStyle += '} ';
dynamicStyle += '} ';
dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) {';
dynamicStyle += 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] {';
dynamicStyle += 'min-height: ' + size.mobile + 'px;';
dynamicStyle += '} ';
dynamicStyle += '} ';
astra_add_dynamic_css( 'ast-dynamic-archive-' + postType + '-banner-height', dynamicStyle );
}
} );
} );
astra_css(
'astra-settings[ast-dynamic-archive-' + postType + '-vertical-alignment]',
'justify-content',
selector
);
astra_css(
'astra-settings[ast-dynamic-archive-' + postType + '-banner-custom-width]',
'max-width',
'body .ast-archive-entry-banner[data-post-type="' + postType + '"][data-banner-width-type="custom"]',
'px'
);
astra_css(
'astra-settings[ast-dynamic-archive-' + postType + '-elements-gap]',
'margin-bottom',
'' + layout1BodySelector + ' .ast-archive-description > *:not(:last-child), body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container > *:not(:last-child)',
'px'
);
astra_css(
'astra-settings[ast-dynamic-archive-' + postType + '-banner-text-color]',
'color',
'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container *, ' + layout1BodySelector + ' .ast-archive-description *'
);
astra_css(
'astra-settings[ast-dynamic-archive-' + postType + '-banner-title-color]',
'color',
'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container h1, ' + layout1BodySelector + ' .ast-archive-description .ast-archive-title, body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container h1 *, ' + layout1BodySelector + ' .ast-archive-description .ast-archive-title *'
);
astra_css(
'astra-settings[ast-dynamic-archive-' + postType + '-banner-link-color]',
'color',
'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container a, ' + layout1BodySelector + ' .ast-archive-description a, body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container a *, ' + layout1BodySelector + ' .ast-archive-description a *'
);
astra_css(
'astra-settings[ast-dynamic-archive-' + postType + '-banner-link-hover-color]',
'color',
'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container a:hover, ' + layout1BodySelector + ' .ast-archive-description a:hover, body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container a:hover *, ' + layout1BodySelector + ' .ast-archive-description a:hover *'
);
astra_apply_responsive_background_css( 'astra-settings[ast-dynamic-archive-' + postType + '-banner-custom-bg]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"][data-banner-background-type="custom"], ' + layout1BodySelector + ' .ast-archive-description', 'desktop' );
astra_apply_responsive_background_css( 'astra-settings[ast-dynamic-archive-' + postType + '-banner-custom-bg]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"][data-banner-background-type="custom"], ' + layout1BodySelector + ' .ast-archive-description', 'tablet' );
astra_apply_responsive_background_css( 'astra-settings[ast-dynamic-archive-' + postType + '-banner-custom-bg]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"][data-banner-background-type="custom"], ' + layout1BodySelector + ' .ast-archive-description', 'mobile' );
astra_responsive_spacing( 'astra-settings[ast-dynamic-archive-' + postType + '-banner-padding]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"], ' + layout1BodySelector + ' .ast-archive-description', 'padding', ['top', 'right', 'bottom', 'left' ] );
astra_responsive_spacing( 'astra-settings[ast-dynamic-archive-' + postType + '-banner-margin]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"], ' + layout1BodySelector + ' .ast-archive-description', 'margin', ['top', 'right', 'bottom', 'left' ] );
// Banner - Title.
astra_generate_outside_font_family_css( 'astra-settings[ast-dynamic-archive-' + postType + '-title-font-family]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] h1, ' + layout1BodySelector + ' .ast-archive-description h1, body .ast-archive-entry-banner[data-post-type="' + postType + '"] h1 *, ' + layout1BodySelector + ' .ast-archive-description h1 *' );
astra_generate_font_weight_css( 'astra-settings[ast-dynamic-archive-' + postType + '-title-font-family]', 'astra-settings[ast-dynamic-archive-' + postType + '-title-font-weight]', 'font-weight', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] h1, ' + layout1BodySelector + ' .ast-archive-description h1, body .ast-archive-entry-banner[data-post-type="' + postType + '"] h1 *, ' + layout1BodySelector + ' .ast-archive-description h1 *' );
astra_css( 'astra-settings[ast-dynamic-archive-' + postType + '-title-font-weight]', 'font-weight', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container h1, ' + layout1BodySelector + ' .ast-archive-description h1, body .ast-archive-entry-banner[data-post-type="' + postType + '"] h1 *, ' + layout1BodySelector + ' .ast-archive-description h1 *' );
astra_responsive_font_size( 'astra-settings[ast-dynamic-archive-' + postType + '-title-font-size]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container h1, ' + layout1BodySelector + ' .ast-archive-description .ast-archive-title, body .ast-archive-entry-banner[data-post-type="' + postType + '"] h1 *, ' + layout1BodySelector + ' .ast-archive-description .ast-archive-title *' );
astra_font_extras_css( 'ast-dynamic-archive-' + postType + '-title-font-extras', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container h1, ' + layout1BodySelector + ' .ast-archive-description .ast-archive-title, body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container h1 *, ' + layout1BodySelector + ' .ast-archive-description h1 *' );
// Banner - Text.
astra_generate_outside_font_family_css( 'astra-settings[ast-dynamic-archive-' + postType + '-text-font-family]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"], body .ast-archive-entry-banner[data-post-type="' + postType + '"] *, ' + layout1BodySelector + ' .ast-archive-description, ' + layout1BodySelector + ' .ast-archive-description *' );
astra_generate_font_weight_css( 'astra-settings[ast-dynamic-archive-' + postType + '-text-font-family]', 'astra-settings[ast-dynamic-archive-' + postType + '-text-font-weight]', 'font-weight', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"], body .ast-archive-entry-banner[data-post-type="' + postType + '"] *, ' + layout1BodySelector + ' .ast-archive-description, ' + layout1BodySelector + ' .ast-archive-description *' );
astra_css( 'astra-settings[ast-dynamic-archive-' + postType + '-text-font-weight]', 'font-weight', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"], body .ast-archive-entry-banner[data-post-type="' + postType + '"] *, ' + layout1BodySelector + ' .ast-archive-description, ' + layout1BodySelector + ' .ast-archive-description *' );
astra_responsive_font_size( 'astra-settings[ast-dynamic-archive-' + postType + '-text-font-size]', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"], body .ast-archive-entry-banner[data-post-type="' + postType + '"] *, ' + layout1BodySelector + ' .ast-archive-description, ' + layout1BodySelector + ' .ast-archive-description *' );
astra_font_extras_css( 'ast-dynamic-archive-' + postType + '-text-font-extras', 'body .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container *, ' + layout1BodySelector + ' .ast-archive-description *' );
}
/**
* For special pages.
*/
for ( var index = 0; index < specialsTypesCount; index++ ) {
var postType = specialsTypes[ index ],
sectionKey = 'section-' + postType + '-page-title',
sectionAstraSettingKey = 'astra-settings[' + sectionKey,
layoutType = ( undefined !== wp.customize( sectionAstraSettingKey + '-layout]' ) ) ? wp.customize( sectionAstraSettingKey + '-layout]' ).get() : 'both',
selector = '.search .ast-archive-entry-banner, .search .ast-archive-description';
astra_refresh_customizer(
sectionAstraSettingKey + '-custom-title]'
);
astra_refresh_customizer(
sectionAstraSettingKey + '-custom-description]'
);
astra_dynamic_build_css(
sectionKey + '-horizontal-alignment',
sectionAstraSettingKey + '-horizontal-alignment]',
'text-align',
selector
);
astra_dynamic_build_css(
sectionKey + '-banner-height',
sectionAstraSettingKey + '-banner-height]',
'min-height',
selector,
'px'
);
wp.customize( sectionAstraSettingKey + 'banner-width-type]', function( value ) {
value.bind( function( type ) {
if ( 'custom' === type ) {
jQuery(selector).attr( 'data-banner-width-type', 'custom' );
var customWidthSize = wp.customize( sectionAstraSettingKey + 'banner-custom-width]' ).get(),
dynamicStyle = '';
dynamicStyle += selector + '[data-banner-width-type="custom"] {';
dynamicStyle += 'max-width: ' + customWidthSize + 'px;';
dynamicStyle += '} ';
astra_add_dynamic_css( sectionKey + '-banner-width-type', dynamicStyle );
} else {
jQuery(selector).attr( 'data-banner-width-type', 'full' );
}
} );
} );
wp.customize( sectionAstraSettingKey + '-banner-height]', function( value ) {
value.bind( function( size ) {
if( size.desktop != '' || size.tablet != '' || size.mobile != '' ) {
var dynamicStyle = '';
dynamicStyle += selector + ' {';
dynamicStyle += 'min-height: ' + size.desktop + 'px;';
dynamicStyle += '} ';
dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) {';
dynamicStyle += selector + ' {';
dynamicStyle += 'min-height: ' + size.tablet + 'px;';
dynamicStyle += '} ';
dynamicStyle += '} ';
dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) {';
dynamicStyle += selector + ' {';
dynamicStyle += 'min-height: ' + size.mobile + 'px;';
dynamicStyle += '} ';
dynamicStyle += '} ';
astra_add_dynamic_css( sectionKey + '-banner-height', dynamicStyle );
}
} );
} );
astra_css(
sectionAstraSettingKey + '-vertical-alignment]',
'justify-content',
selector
);
astra_css(
sectionAstraSettingKey + '-banner-custom-width]',
'max-width',
selector + '[data-banner-width-type="custom"]',
'px'
);
astra_css(
sectionAstraSettingKey + '-elements-gap]',
'margin-bottom',
'.search .ast-archive-description > *:not(:last-child), .search .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container > *:not(:last-child)',
'px'
);
astra_css(
sectionAstraSettingKey + '-banner-text-color]',
'color',
'.search .ast-archive-entry-banner .ast-container *, .search .ast-archive-description *'
);
astra_css(
sectionAstraSettingKey + '-banner-title-color]',
'color',
'.search .ast-archive-entry-banner .ast-container h1, .search .ast-archive-description h1, .search .ast-archive-entry-banner .ast-container h1 *, .search .ast-archive-description h1 *'
);
astra_css(
sectionAstraSettingKey + '-banner-link-color]',
'color',
selector + ' .ast-container a, ' + '.search .ast-archive-description a, .search .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container a *, ' + '.search .ast-archive-description a *'
);
astra_css(
sectionAstraSettingKey + '-banner-link-hover-color]',
'color',
selector + ' .ast-container a:hover, ' + '.search .ast-archive-description a:hover, .search .ast-archive-entry-banner[data-post-type="' + postType + '"] .ast-container a:hover *, ' + '.search .ast-archive-description a:hover *'
);
astra_apply_responsive_background_css( sectionAstraSettingKey + '-banner-custom-bg]', '.search .ast-archive-entry-banner[data-banner-background-type="custom"], .search .ast-archive-description', 'desktop' );
astra_apply_responsive_background_css( sectionAstraSettingKey + '-banner-custom-bg]', '.search .ast-archive-entry-banner[data-banner-background-type="custom"], .search .ast-archive-description', 'tablet' );
astra_apply_responsive_background_css( sectionAstraSettingKey + '-banner-custom-bg]', '.search .ast-archive-entry-banner[data-banner-background-type="custom"], .search .ast-archive-description', 'mobile' );
astra_responsive_spacing( sectionAstraSettingKey + '-banner-padding]', selector + ', ' + '.search .ast-archive-description', 'padding', ['top', 'right', 'bottom', 'left' ] );
astra_responsive_spacing( sectionAstraSettingKey + '-banner-margin]', selector + ', ' + '.search .ast-archive-description', 'margin', ['top', 'right', 'bottom', 'left' ] );
// Banner - Title.
astra_generate_outside_font_family_css( sectionAstraSettingKey + '-title-font-family]', '.search .ast-archive-entry-banner .ast-container h1, .search .ast-archive-description h1, .search .ast-archive-description .ast-archive-title, .search .ast-archive-entry-banner .ast-container h1 *, .search .ast-archive-description h1 *' );
astra_generate_font_weight_css( sectionAstraSettingKey + '-title-font-family]', sectionAstraSettingKey + '-title-font-weight]', 'font-weight', '.search .ast-archive-entry-banner .ast-container h1, .search .ast-archive-description h1, .search .ast-archive-description .ast-archive-title, .search .ast-archive-entry-banner .ast-container h1 *, .search .ast-archive-description h1 *' );
astra_css( sectionAstraSettingKey + '-title-font-weight]', 'font-weight', '.search .ast-archive-entry-banner .ast-container h1, .search .ast-archive-description h1, .search .ast-archive-description .ast-archive-title, .search .ast-archive-entry-banner .ast-container h1 *, .search .ast-archive-description h1 *' );
astra_responsive_font_size( sectionAstraSettingKey + '-title-font-size]', '.search .ast-archive-entry-banner .ast-container h1, .search .ast-archive-description h1, .search .ast-archive-description .ast-archive-title, .search .ast-archive-entry-banner .ast-container h1 *, .search .ast-archive-description h1 *' );
astra_font_extras_css( sectionKey + '-title-font-extras', '.search .ast-archive-entry-banner .ast-container h1, .search .ast-archive-description h1, .search .ast-archive-description .ast-archive-title, .search .ast-archive-entry-banner .ast-container h1 *, .search .ast-archive-description h1 *' );
// Banner - Text.
astra_generate_outside_font_family_css( sectionAstraSettingKey + '-text-font-family]', '.search .ast-archive-description *, .search .ast-archive-entry-banner .ast-container *' );
astra_generate_font_weight_css( sectionAstraSettingKey + '-text-font-family]', sectionAstraSettingKey + '-text-font-weight]', 'font-weight', '.search .ast-archive-description *, .search .ast-archive-entry-banner .ast-container *' );
astra_css( sectionAstraSettingKey + '-text-font-weight]', 'font-weight', '.search .ast-archive-description *, .search .ast-archive-entry-banner .ast-container *' );
astra_responsive_font_size( sectionAstraSettingKey + '-text-font-size]', '.search .ast-archive-description *, .search .ast-archive-entry-banner .ast-container *' );
astra_font_extras_css( sectionKey + '-text-font-extras', '.search .ast-archive-description *, .search .ast-archive-entry-banner .ast-container *' );
}
} )( jQuery );

View File

@@ -0,0 +1,45 @@
<?php
/**
* Post Strctures Extension
*
* @package Astra
* @since 4.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'ASTRA_THEME_POST_STRUCTURE_DIR', ASTRA_THEME_DIR . 'inc/modules/posts-structures/' );
define( 'ASTRA_THEME_POST_STRUCTURE_URI', ASTRA_THEME_URI . 'inc/modules/posts-structures/' );
/**
* Post Strctures Initial Setup
*
* @since 4.0.0
*/
class Astra_Post_Structures {
/**
* Constructor function that loads require files.
*/
public function __construct() {
// @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'class-astra-posts-structure-loader.php';
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'class-astra-posts-structure-markup.php';
// Include front end files.
if ( ! is_admin() ) {
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'css/single-dynamic.css.php';
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'css/archive-dynamic.css.php';
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'css/special-dynamic.css.php';
}
// @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
}
}
/**
* Kicking this off by creating new object.
*/
new Astra_Post_Structures();

View File

@@ -0,0 +1,320 @@
<?php
/**
* Post Structures loader for Astra theme.
*
* @package Astra
* @link https://www.brainstormforce.com
* @since Astra 4.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Customizer Initialization
*
* @since 4.0.0
*/
class Astra_Posts_Structure_Loader {
/**
* Instance
*
* @var array $customizer_defaults
*/
private static $customizer_defaults = array();
/**
* Supported post types to process dynamic customizer.
*
* @var array $supported_post_types
*/
private static $supported_post_types = array();
/**
* Constructor
*
* @since 4.0.0
*/
public function __construct() {
/**
* Update Astra default color and typography values. To not update directly on existing users site, added backwards.
*
* @since 4.0.0
*/
$apply_new_default_color_typo_values = Astra_Dynamic_CSS::astra_check_default_color_typo();
self::$customizer_defaults['responsive-background'] = array(
'desktop' => array(
'background-color' => '',
'background-image' => '',
'background-repeat' => 'repeat',
'background-position' => 'center center',
'background-size' => 'auto',
'background-attachment' => 'scroll',
'overlay-type' => '',
'overlay-color' => '',
'overlay-opacity' => '',
'overlay-gradient' => '',
'background-type' => '',
'background-media' => '',
),
'tablet' => array(
'background-color' => '',
'background-image' => '',
'background-repeat' => 'repeat',
'background-position' => 'center center',
'background-size' => 'auto',
'background-attachment' => 'scroll',
'overlay-type' => '',
'overlay-color' => '',
'overlay-opacity' => '',
'overlay-gradient' => '',
'background-type' => '',
'background-media' => '',
),
'mobile' => array(
'background-color' => '',
'background-image' => '',
'background-repeat' => 'repeat',
'background-position' => 'center center',
'background-size' => 'auto',
'background-attachment' => 'scroll',
'overlay-type' => '',
'overlay-color' => '',
'overlay-opacity' => '',
'overlay-gradient' => '',
'background-type' => '',
'background-media' => '',
),
);
self::$customizer_defaults['responsive-spacing'] = array(
'desktop' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'tablet' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'mobile' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'desktop-unit' => 'px',
'tablet-unit' => 'px',
'mobile-unit' => 'px',
);
self::$customizer_defaults['responsive-padding'] = array(
'desktop' => array(
'top' => 3,
'right' => 3,
'bottom' => 3,
'left' => 3,
),
'tablet' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'mobile' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'desktop-unit' => 'em',
'tablet-unit' => 'em',
'mobile-unit' => 'em',
);
self::$customizer_defaults['font-size'] = array(
'desktop' => '',
'tablet' => '',
'mobile' => '',
'desktop-unit' => 'px',
'tablet-unit' => 'px',
'mobile-unit' => 'px',
);
self::$customizer_defaults['title-font-size'] = array(
'desktop' => $apply_new_default_color_typo_values ? '32' : '',
'tablet' => '',
'mobile' => '',
'desktop-unit' => 'px',
'tablet-unit' => 'px',
'mobile-unit' => 'px',
);
self::$customizer_defaults['title-font-weight'] = $apply_new_default_color_typo_values ? '600' : 'inherit';
self::$customizer_defaults['responsive-slider'] = array(
'desktop' => '',
'tablet' => '',
'mobile' => '',
);
self::$customizer_defaults['responsive-color'] = array(
'desktop' => '',
'tablet' => '',
'mobile' => '',
);
self::$customizer_defaults['font-extras'] = array(
'line-height' => '',
'line-height-unit' => 'em',
'letter-spacing' => '',
'letter-spacing-unit' => 'px',
'text-transform' => '',
'text-decoration' => '',
);
add_action( 'customize_register', array( $this, 'posts_structures_customize_register' ), 2 );
add_action( 'astra_get_fonts', array( $this, 'add_fonts' ), 1 );
add_action( 'customize_preview_init', array( $this, 'preview_scripts' ) );
}
/**
* Enqueue google fonts.
*
* @return void
* @since 4.0.0
*/
public function add_fonts() {
$post_types = self::get_supported_post_types();
foreach ( $post_types as $index => $post_type ) {
// Single Banner - Font Support.
$title_section = 'ast-dynamic-single-' . $post_type;
$single_title_font_family = astra_get_option( $title_section . '-title-font-family' );
$single_title_font_weight = astra_get_option( $title_section . '-title-font-weight' );
Astra_Fonts::add_font( $single_title_font_family, $single_title_font_weight );
$single_text_font_family = astra_get_option( $title_section . '-text-font-family' );
$single_text_font_weight = astra_get_option( $title_section . '-text-font-weight' );
Astra_Fonts::add_font( $single_text_font_family, $single_text_font_weight );
$single_meta_font_family = astra_get_option( $title_section . '-meta-font-family' );
$single_meta_font_weight = astra_get_option( $title_section . '-meta-font-weight' );
Astra_Fonts::add_font( $single_meta_font_family, $single_meta_font_weight );
// Archive Banner - Font Support.
$title_section = 'ast-dynamic-archive-' . $post_type;
$archive_text_font_family = astra_get_option( $title_section . '-text-font-family' );
$archive_text_font_weight = astra_get_option( $title_section . '-text-font-weight' );
Astra_Fonts::add_font( $archive_text_font_family, $archive_text_font_weight );
$archive_title_font_family = astra_get_option( $title_section . '-title-font-family' );
$archive_title_font_weight = astra_get_option( $title_section . '-title-font-weight' );
Astra_Fonts::add_font( $archive_title_font_family, $archive_title_font_weight );
}
foreach ( self::get_special_page_types() as $index => $special_type ) {
$title_section = 'section-' . $special_type . '-page-title';
$instance_text_font_family = astra_get_option( $title_section . '-text-font-family' );
$instance_text_font_weight = astra_get_option( $title_section . '-text-font-weight' );
Astra_Fonts::add_font( $instance_text_font_family, $instance_text_font_weight );
$instance_title_font_family = astra_get_option( $title_section . '-title-font-family' );
$instance_title_font_weight = astra_get_option( $title_section . '-title-font-weight' );
Astra_Fonts::add_font( $instance_title_font_family, $instance_title_font_weight );
}
}
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*
* @since 4.0.0
*/
public function posts_structures_customize_register( $wp_customize ) {
/**
* Register Config control in Related Posts.
*/
// @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'customizer/class-astra-posts-structures-configs.php';
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'customizer/class-astra-posts-single-structures-configs.php';
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'customizer/class-astra-posts-archive-structures-configs.php';
require_once ASTRA_THEME_POST_STRUCTURE_DIR . 'customizer/class-astra-posts-special-archive-structures-configs.php';
// @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
}
/**
* Get all supported pots types & filter the public ones for further query.
*
* @since 4.0.0
* @return array $post_types
*/
public static function get_supported_post_types() {
if ( empty( self::$supported_post_types ) || is_customize_preview() ) {
self::$supported_post_types = astra_get_queried_post_types();
}
return apply_filters( 'astra_dynamic_post_structure_posttypes', self::$supported_post_types );
}
/**
* Get special pages query.
*
* @since 4.6.0
* @return array $special_pages
*/
public static function get_special_page_types() {
$special_pages = array(
'search',
);
return apply_filters( 'astra_dynamic_special_pages', $special_pages );
}
/**
* Customizer preview support.
*
* @since 4.0.0
*/
public function preview_scripts() {
/** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified';
/** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
/** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$file_prefix = ( SCRIPT_DEBUG ) ? '' : '.min';
/** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
wp_enqueue_script( 'astra-post-strctures-customizer-preview', ASTRA_THEME_POST_STRUCTURE_URI . 'assets/js/' . $dir_name . '/customizer-preview' . $file_prefix . '.js', array( 'customize-preview', 'astra-customizer-preview-js' ), ASTRA_THEME_VERSION, true );
// Localize variables for further JS.
wp_localize_script(
'astra-post-strctures-customizer-preview',
'AstraPostStrcturesData',
array(
'post_types' => self::get_supported_post_types(),
'special_pages' => self::get_special_page_types(),
'tablet_break_point' => astra_get_tablet_breakpoint(),
'mobile_break_point' => astra_get_mobile_breakpoint(),
'enabled_related_post' => astra_get_option( 'enable-related-posts', false ),
)
);
}
/**
* Get customizer dynamic default.
*
* @param string $key Retrieve default for this parameter.
*
* @since 4.0.0
*/
public static function get_customizer_default( $key ) {
return isset( self::$customizer_defaults[ $key ] ) ? self::$customizer_defaults[ $key ] : array();
}
}
/**
* Initialize class object with 'new' instance.
*/
new Astra_Posts_Structure_Loader();

View File

@@ -0,0 +1,253 @@
<?php
/**
* Hero section layout for Astra theme.
*
* @package Astra
* @link https://www.brainstormforce.com
* @since Astra 4.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Breadcrumbs Markup Initial Setup
*
* @since 4.0.0
*/
class Astra_Posts_Structure_Markup {
/**
* Constructor
*/
public function __construct() {
$astra_banner_hook = apply_filters( 'astra_banner_hook', 'astra_content_before' );
add_action( esc_attr( $astra_banner_hook ), array( $this, 'astra_add_hero_section_markup' ), 99 );
}
/**
* Check eligibility to override default entry header.
*
* @since 4.0.0
* @return void
*/
public function astra_add_hero_section_markup() {
if ( apply_filters( 'astra_apply_hero_header_banner', true ) ) {
$this->override_entry_header();
}
}
/**
* Support custom title & description support for archive.
*
* @param string $title Default archive title.
* @since 4.0.0
* @return string
*/
public function astra_archive_custom_title( $title ) {
$post_type = astra_get_post_type();
$custom_title = astra_get_option( 'ast-dynamic-archive-' . $post_type . '-custom-title', '' );
$title = ! empty( $custom_title ) ? $custom_title : $title;
return $title;
}
/**
* Override default entry header.
*
* @since 4.0.0
* @return void
*/
public function override_entry_header() {
if ( is_front_page() && 'page' === get_option( 'show_on_front' ) && astra_get_option( 'ast-dynamic-single-page-disable-structure-meta-on-front-page', false ) ) {
return;
}
if ( is_search() ) {
if ( true === astra_get_option( 'ast-search-page-title', true ) ) {
if ( 'layout-2' === astra_get_option( 'section-search-page-title-layout', 'layout-1' ) ) {
$type = 'search';
do_action( 'astra_before_archive_' . $type . '_banner_content' );
get_template_part( 'template-parts/special-banner' );
do_action( 'astra_after_archive_' . $type . '_banner_content' );
remove_action( 'astra_archive_header', 'astra_archive_page_info' );
return;
}
} else {
add_filter( 'astra_the_title_enabled', '__return_false' );
return;
}
}
$post_type = astra_get_post_type();
$type = is_singular( $post_type ) ? 'single' : 'archive';
$supported_post_types = Astra_Posts_Structure_Loader::get_supported_post_types();
if ( ! in_array( $post_type, $supported_post_types ) ) {
return;
}
$layout_type = ( 'single' === $type ) ? astra_get_option( 'ast-dynamic-single-' . $post_type . '-layout', 'layout-1' ) : astra_get_option( 'ast-dynamic-archive-' . $post_type . '-layout', 'layout-1' );
// If banner title section is disabled then halt further processing.
if ( 'single' === $type ) {
if ( false === astra_get_option( 'ast-single-' . $post_type . '-title', ( class_exists( 'WooCommerce' ) && 'product' === $post_type ) ? false : true ) ) {
add_filter( 'astra_single_layout_one_banner_visibility', '__return_false' );
return;
}
$visibility = get_post_meta( absint( astra_get_post_id() ), 'ast-banner-title-visibility', true );
$visibility = apply_filters( 'astra_banner_title_area_visibility', $visibility );
if ( 'disabled' === $visibility ) {
add_filter( 'astra_single_layout_one_banner_visibility', '__return_false' );
return;
}
} else {
// If layout-1 is set then no need to process further.
if ( false === astra_get_option( 'ast-archive-' . $post_type . '-title', ( class_exists( 'WooCommerce' ) && 'product' === $post_type ) ? false : true ) ) {
add_filter( 'astra_the_title_enabled', '__return_false' );
return;
}
if ( 'layout-1' === $layout_type ) {
// WooCommerce specific compatibility - As layout-1 support needs to add externally.
if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() ) ) {
$this->astra_woocommerce_banner_layout_1_compatibility();
add_action( 'astra_primary_content_top', array( $this, 'astra_force_render_banner_layout_1' ) );
}
return;
}
add_filter( 'astra_the_title_enabled', '__return_false' );
}
if ( 'single' === $type && 'layout-2' === $layout_type ) {
do_action( 'astra_before_single_' . $post_type . '_banner_content' );
get_template_part( 'template-parts/single-banner' );
do_action( 'astra_after_single_' . $post_type . '_banner_content' );
add_filter( 'astra_remove_entry_header_content', '__return_true' );
add_filter( 'astra_single_layout_one_banner_visibility', '__return_false' );
} elseif ( ( is_front_page() && is_home() ) || ( is_home() ) ) {
if ( true === astra_get_option( 'ast-dynamic-archive-post-banner-on-blog', false ) ) {
// For latest posts page.
add_filter( 'astra_the_default_home_page_title', array( $this, 'astra_archive_custom_title' ) );
// For blog page.
add_filter( 'astra_the_blog_home_page_title', array( $this, 'astra_archive_custom_title' ) );
do_action( 'astra_before_archive_' . $post_type . '_banner_content' );
get_template_part( 'template-parts/archive-banner' );
do_action( 'astra_after_archive_' . $post_type . '_banner_content' );
remove_filter( 'astra_the_default_home_page_title', array( $this, 'astra_archive_custom_title' ) );
remove_filter( 'astra_the_blog_home_page_title', array( $this, 'astra_archive_custom_title' ) );
}
} elseif ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() ) ) {
$this->astra_woocommerce_banner_layout_1_compatibility();
do_action( 'astra_before_archive_' . $post_type . '_banner_content' );
get_template_part( 'template-parts/archive-banner' );
do_action( 'astra_after_archive_' . $post_type . '_banner_content' );
if ( is_shop() ) {
remove_filter( 'woocommerce_page_title', array( $this, 'astra_archive_custom_title' ) );
}
} elseif ( class_exists( 'WooCommerce' ) && 'single' === $type && 'product' === $post_type && 'layout-1' === $layout_type ) {
// Adding layout 1 support to Product post type for single layout.
add_action( 'astra_primary_content_top', array( $this, 'astra_force_render_banner_layout_1' ) );
} elseif ( 'archive' === $type ) {
$is_post_type_archive = is_post_type_archive( $post_type ) ? true : false;
if ( $is_post_type_archive ) {
add_filter( 'get_the_archive_title', array( $this, 'astra_archive_custom_title' ) );
}
do_action( 'astra_before_archive_' . $post_type . '_banner_content' );
get_template_part( 'template-parts/archive-banner' );
do_action( 'astra_after_archive_' . $post_type . '_banner_content' );
if ( $is_post_type_archive ) {
remove_filter( 'get_the_archive_title', array( $this, 'astra_archive_custom_title' ) );
}
}
}
/**
* Layout 1 will also needed for WooCommerce product.
* Case: WooCommerce by default adds "Shop" title, breadcrumb on shop/product-archive frontend, but this should also get linked to banner layout 1.
*
* @since 4.0.0
* @return void
*/
public function astra_woocommerce_banner_layout_1_compatibility() {
// For custom title page.
if ( is_shop() ) {
add_filter( 'woocommerce_page_title', array( $this, 'astra_archive_custom_title' ) );
}
add_filter( 'woocommerce_show_page_title', '__return_false' );
remove_action(
'woocommerce_before_main_content',
'woocommerce_breadcrumb',
20
);
remove_action(
'woocommerce_archive_description',
'woocommerce_taxonomy_archive_description'
);
remove_action(
'woocommerce_archive_description',
'woocommerce_product_archive_description'
);
}
/**
* Enable layout 1 for some cases. Ex. WC Product.
*
* @since 4.0.0
* @return void
*/
public function astra_force_render_banner_layout_1() {
$is_singular = is_singular() ? true : false;
if ( $is_singular ) {
?> <header class="entry-header <?php astra_entry_header_class(); ?>">
<?php
astra_single_header_top();
} else {
?>
<section class="ast-archive-description">
<?php
do_action( 'astra_before_archive_title' );
}
astra_banner_elements_order();
if ( $is_singular ) {
?>
</header> <!-- .entry-header -->
<?php
astra_single_header_bottom();
} else {
?>
</section>
<?php
do_action( 'astra_after_archive_title' );
}
}
}
new Astra_Posts_Structure_Markup();

View File

@@ -0,0 +1,439 @@
<?php
/**
* Post Structures - Archive Dynamic CSS
*
* @package Astra
* @since 4.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Post Structures
*/
add_filter( 'astra_dynamic_theme_css', 'astra_post_archive_structure_dynamic_css' );
/**
* Archive Dynamic CSS
*
* @param string $dynamic_css Astra Dynamic CSS.
* @param string $dynamic_css_filtered Astra Dynamic CSS Filters.
* @return String Generated dynamic CSS for Post Structures.
*
* @since 4.0.0
*/
function astra_post_archive_structure_dynamic_css( $dynamic_css, $dynamic_css_filtered = '' ) {
$current_post_type = astra_get_post_type();
$supported_post_types = Astra_Posts_Structure_Loader::get_supported_post_types();
if ( is_search() || ! in_array( $current_post_type, $supported_post_types ) ) {
return $dynamic_css;
}
if ( false === astra_get_option( 'ast-archive-' . $current_post_type . '-title', ( class_exists( 'WooCommerce' ) && 'product' === $current_post_type ) ? false : true ) ) {
return $dynamic_css;
}
// SureCart Shop Page Banner Support.
$surecart_shop_support = ( defined( 'SURECART_PLUGIN_FILE' ) && is_page() && get_the_ID() === absint( get_option( 'surecart_shop_page_id' ) ) ) ? true : false;
if ( $surecart_shop_support ) {
$current_post_type = 'sc_product';
}
$layout_type = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-layout', 'layout-1' );
$layout_2_active = ( 'layout-2' === $layout_type ) ? true : false;
if ( $layout_2_active ) {
$selector = '.ast-archive-entry-banner[data-post-type="' . $current_post_type . '"]';
} else {
if ( $surecart_shop_support ) {
$selector = 'body.page .ast-archive-description';
} else {
$selector = 'body.archive .ast-archive-description';
}
}
$horz_alignment = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-horizontal-alignment' );
$desk_h_alignment = ( isset( $horz_alignment['desktop'] ) ) ? $horz_alignment['desktop'] : '';
$tab_h_alignment = ( isset( $horz_alignment['tablet'] ) ) ? $horz_alignment['tablet'] : '';
$mob_h_alignment = ( isset( $horz_alignment['mobile'] ) ) ? $horz_alignment['mobile'] : '';
if ( 'layout-1' === $layout_type ) {
$desk_h_alignment = ( '' !== $desk_h_alignment ) ? $desk_h_alignment : 'left';
$tab_h_alignment = ( '' !== $tab_h_alignment ) ? $tab_h_alignment : 'left';
$mob_h_alignment = ( '' !== $mob_h_alignment ) ? $mob_h_alignment : 'left';
}
$elements_gap = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-elements-gap', 10 );
$banner_padding = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-padding', ( class_exists( 'WooCommerce' ) && 'product' === $current_post_type ) ? Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-spacing' ) : Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-padding' ) );
$banner_margin = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-margin' );
$banner_height = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-height' );
$desk_banner_height = ( $layout_2_active && isset( $banner_height['desktop'] ) ) ? astra_get_css_value( $banner_height['desktop'], 'px' ) : '';
$tab_banner_height = ( $layout_2_active && isset( $banner_height['tablet'] ) ) ? astra_get_css_value( $banner_height['tablet'], 'px' ) : '';
$mob_banner_height = ( $layout_2_active && isset( $banner_height['mobile'] ) ) ? astra_get_css_value( $banner_height['mobile'], 'px' ) : '';
$text_color = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-text-color' );
$title_color = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-title-color' );
$link_color = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-link-color' );
$link_hover_color = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-link-hover-color' );
$vert_alignment = ( $layout_2_active ) ? astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-vertical-alignment', 'center' ) : 'center';
$width_type = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-width-type', 'fullwidth' );
$custom_width = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-custom-width', 1200 );
$background_type = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-image-type', 'none' );
// Banner Text typography dynamic stylings.
$banner_text_font_size = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-text-font-size' );
// Banner Title typography dynamic stylings.
$banner_title_font_size = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-title-font-size', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-size' ) );
$css_output_min_tablet = array();
$narrow_container_width = astra_get_option( 'narrow-container-max-width', apply_filters( 'astra_narrow_container_width', 750 ) );
// Few settings from banner section are also applicable to 'layout-1' so adding this condition & compatibility.
if ( 'layout-1' === $layout_type ) {
$site_content_width = astra_get_option( 'site-content-width', 1200 );
/**
* Desktop CSS.
*/
$css_output_desktop = array(
$selector => array(
'max-width' => $site_content_width . 'px',
'width' => '100%',
'text-align' => $desk_h_alignment,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'desktop' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'desktop' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'desktop' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'desktop' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'desktop' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'desktop' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'desktop' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'desktop' ),
),
$selector . ' *' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-text-font-family' ), astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-text-font-weight' ), $banner_text_font_size, 'ast-dynamic-archive-' . $current_post_type . '-text-font-extras', $text_color ),
$selector . ' .ast-archive-title, ' . $selector . ' .ast-archive-title *' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-title-font-family' ), astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-title-font-weight', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-weight' ) ), $banner_title_font_size, 'ast-dynamic-archive-' . $current_post_type . '-title-font-extras', $title_color ),
$selector . ' a, ' . $selector . ' a *' => array(
'color' => esc_attr( $link_color ),
),
$selector . ' a:hover, ' . $selector . ' a:hover *' => array(
'color' => esc_attr( $link_hover_color ),
),
$selector . ' > *:not(:last-child)' => array(
'margin-bottom' => $elements_gap . 'px',
),
);
/**
* Tablet CSS.
*/
$css_output_tablet = array(
$selector => array(
'text-align' => $tab_h_alignment,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'tablet' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'tablet' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'tablet' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'tablet' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'tablet' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'tablet' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'tablet' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'tablet' ),
),
$selector . ' .ast-archive-title' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'tablet' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'tablet' ),
),
);
/**
* Mobile CSS.
*/
$css_output_mobile = array(
$selector => array(
'text-align' => $mob_h_alignment,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'mobile' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'mobile' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'mobile' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'mobile' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'mobile' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'mobile' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'mobile' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'mobile' ),
),
$selector . ' .ast-archive-title' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'mobile' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'mobile' ),
),
);
if ( 'none' !== $background_type ) {
if ( class_exists( 'WooCommerce' ) && 'product' === $current_post_type ) {
if ( 'custom' === $background_type ) {
$custom_background = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-custom-bg' );
$css_output_desktop['.archive section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'desktop' );
$css_output_tablet['.archive section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'tablet' );
$css_output_mobile['.archive section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'mobile' );
} else {
// @codingStandardsIgnoreStart
/**
* @psalm-suppress RedundantCondition
* @psalm-suppress InvalidGlobal
*/
global $wp_query;
/**
* @psalm-suppress RedundantCondition
* @psalm-suppress InvalidGlobal
*/
// @codingStandardsIgnoreEnd
$overlay_color = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-featured-overlay', '' );
$taxonomy = $wp_query->get_queried_object();
if ( is_callable( 'is_shop' ) && is_shop() && '' !== $overlay_color ) {
$css_output_desktop['.archive section.ast-archive-description']['background'] = $overlay_color;
}
if ( ! empty( $taxonomy->term_id ) ) {
$thumbnail_id = get_term_meta( $taxonomy->term_id, 'thumbnail_id', true );
$feat_image_src = wp_get_attachment_url( $thumbnail_id );
if ( $feat_image_src ) {
$css_output_desktop['.archive section.ast-archive-description'] = array(
'background' => 'url( ' . esc_url( $feat_image_src ) . ' )',
'background-repeat' => 'no-repeat',
'background-attachment' => 'scroll',
'background-position' => 'center center',
'background-size' => 'cover',
);
if ( '' !== $overlay_color ) {
$css_output_desktop['.archive section.ast-archive-description']['background'] = 'url( ' . esc_url( $feat_image_src ) . ' ) ' . $overlay_color;
$css_output_desktop['.archive section.ast-archive-description']['background-blend-mode'] = 'multiply';
}
}
}
}
} else {
$custom_background = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-custom-bg' );
$css_output_desktop['.archive section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'desktop' );
$css_output_tablet['.archive section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'tablet' );
$css_output_mobile['.archive section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'mobile' );
}
}
} else {
/**
* Desktop CSS.
*/
$css_output_desktop = array(
$selector => array(
'text-align' => $desk_h_alignment,
'justify-content' => $vert_alignment,
'min-height' => $desk_banner_height,
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'desktop' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'desktop' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'desktop' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'desktop' ),
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'desktop' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'desktop' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'desktop' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'desktop' ),
),
$selector . ' .ast-container' => array(
'width' => '100%',
),
$selector . ' .ast-container *' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-text-font-family' ), astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-text-font-weight' ), $banner_text_font_size, 'ast-dynamic-archive-' . $current_post_type . '-text-font-extras', $text_color ),
$selector . ' .ast-container h1' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-title-font-family' ), astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-title-font-weight', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-weight' ) ), $banner_title_font_size, 'ast-dynamic-archive-' . $current_post_type . '-title-font-extras', $title_color ),
'.ast-page-builder-template ' . $selector . ' .ast-container' => array(
'max-width' => '100%',
),
'.ast-narrow-container ' . $selector . ' .ast-container' => array(
'max-width' => $narrow_container_width . 'px',
),
$selector . ' .ast-container a, ' . $selector . ' .ast-container a *' => array(
'color' => esc_attr( $link_color ),
),
$selector . ' .ast-container a:hover, ' . $selector . ' .ast-container a:hover *' => array(
'color' => esc_attr( $link_hover_color ),
),
$selector . ' .ast-container > *:not(:last-child)' => array(
'margin-bottom' => $elements_gap . 'px',
),
$selector . ' .ast-container > *:last-child' => array(
'margin-bottom' => '0',
),
);
/**
* Min tablet width CSS.
*/
$css_output_min_tablet = array(
'.ast-narrow-container ' . $selector . ' .ast-container' => array(
'max-width' => $narrow_container_width . 'px',
'padding-left' => '0',
'padding-right' => '0',
),
);
/**
* Tablet CSS.
*/
$css_output_tablet = array(
$selector => array(
'text-align' => $tab_h_alignment,
'min-height' => $tab_banner_height,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'tablet' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'tablet' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'tablet' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'tablet' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'tablet' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'tablet' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'tablet' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'tablet' ),
),
$selector . ' .ast-container' => array(
'padding-left' => '0',
'padding-right' => '0',
),
$selector . ' .ast-container h1' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'tablet' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'tablet' ),
),
);
/**
* Mobile CSS.
*/
$css_output_mobile = array(
$selector => array(
'text-align' => $mob_h_alignment,
'min-height' => $mob_banner_height,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'mobile' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'mobile' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'mobile' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'mobile' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'mobile' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'mobile' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'mobile' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'mobile' ),
),
$selector . ' .ast-container h1' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'mobile' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'mobile' ),
),
);
if ( ( 'custom' === $width_type ) ) {
$css_output_desktop[ $selector . '[data-banner-width-type="custom"]' ]['max-width'] = $custom_width . 'px';
}
if ( 'none' !== $background_type ) {
if ( 'product' !== $current_post_type ) {
$custom_background = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-custom-bg' );
$css_output_desktop[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'desktop' );
$css_output_tablet[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'tablet' );
$css_output_mobile[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'mobile' );
} else {
if ( 'custom' === $background_type ) {
$custom_background = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-custom-bg' );
$css_output_desktop[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'desktop' );
$css_output_tablet[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'tablet' );
$css_output_mobile[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'mobile' );
} else {
// @codingStandardsIgnoreStart
/**
* @psalm-suppress RedundantCondition
* @psalm-suppress InvalidGlobal
*/
global $wp_query;
/**
* @psalm-suppress RedundantCondition
* @psalm-suppress InvalidGlobal
*/
// @codingStandardsIgnoreEnd
$overlay_color = astra_get_option( 'ast-dynamic-archive-' . $current_post_type . '-banner-featured-overlay', '' );
$taxonomy = $wp_query->get_queried_object();
$feat_image_src = '';
// Checking if the is_shop function and wc_get_page_id are callable.
if ( is_callable( 'is_shop' ) && is_shop() && is_callable( 'wc_get_page_id' ) ) {
$shop_page_id = wc_get_page_id( 'shop' );
// Retrieving the featured image URL of the shop page.
$feat_image_src = get_the_post_thumbnail_url( $shop_page_id );
}
// Checking if we are in a taxonomy (category/archive) page.
if ( ! empty( $taxonomy->term_id ) ) {
$thumbnail_id = get_term_meta( $taxonomy->term_id, 'thumbnail_id', true );
$feat_image_src = wp_get_attachment_url( $thumbnail_id );
}
// Apply the background if a featured image is set.
if ( $feat_image_src ) {
$css_output_desktop[ $selector . '[data-banner-background-type="featured"]' ] = array(
'background' => 'url( ' . esc_url( $feat_image_src ) . ' )',
'background-repeat' => 'no-repeat',
'background-attachment' => 'scroll',
'background-position' => 'center center',
'background-size' => 'cover',
);
// Apply overlay if set.
if ( '' !== $overlay_color ) {
$css_output_desktop[ $selector . '[data-banner-background-type="featured"]' ]['background'] = 'url( ' . esc_url( $feat_image_src ) . ' ) ' . $overlay_color;
$css_output_desktop[ $selector . '[data-banner-background-type="featured"]' ]['background-blend-mode'] = 'multiply';
}
} elseif ( '' !== $overlay_color ) {
// If no featured image is set, apply only the overlay color.
$css_output_desktop[ $selector . '[data-banner-background-type="featured"]' ]['background'] = $overlay_color;
}
}
}
}
}
$dynamic_css .= '
.ast-archive-entry-banner {
-js-display: flex;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
position: relative;
background: #eeeeee;
}
.ast-archive-entry-banner[data-banner-width-type="custom"] {
margin: 0 auto;
width: 100%;
}
.ast-archive-entry-banner[data-banner-layout="layout-1"] {
background: inherit;
padding: 20px 0;
text-align: left;
}
';
if ( is_customize_preview() ) {
$dynamic_css .= '
.site-header-focus-item .ast-container div.customize-partial-edit-shortcut,
.site-header-focus-item .ast-container button.item-customizer-focus {
font-size: inherit;
}
';
}
/* Parse CSS from array() */
$dynamic_css .= astra_parse_css( $css_output_desktop );
$dynamic_css .= astra_parse_css( $css_output_min_tablet, astra_get_tablet_breakpoint( '', 1 ) );
$dynamic_css .= astra_parse_css( $css_output_tablet, '', astra_get_tablet_breakpoint() );
$dynamic_css .= astra_parse_css( $css_output_mobile, '', astra_get_mobile_breakpoint() );
return $dynamic_css;
}

View File

@@ -0,0 +1,516 @@
<?php
/**
* Post Structures - Dynamic CSS
*
* @package Astra
* @since 4.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Post Structures
*/
add_filter( 'astra_dynamic_theme_css', 'astra_post_single_structure_dynamic_css' );
/**
* Dynamic CSS
*
* @param string $dynamic_css Astra Dynamic CSS.
* @param string $dynamic_css_filtered Astra Dynamic CSS Filters.
* @return String Generated dynamic CSS for Post Structures.
*
* @since 4.0.0
*/
function astra_post_single_structure_dynamic_css( $dynamic_css, $dynamic_css_filtered = '' ) {
$current_post_type = strval( get_post_type() );
$supported_post_types = Astra_Posts_Structure_Loader::get_supported_post_types();
if ( ! is_singular( $current_post_type ) ) {
return $dynamic_css;
}
if ( ! in_array( $current_post_type, $supported_post_types ) ) {
return $dynamic_css;
}
if ( 'product' === $current_post_type ) {
$single_section_id = 'section-woo-shop-single';
} elseif ( 'page' === $current_post_type ) {
$single_section_id = 'section-single-page';
} elseif ( 'download' === $current_post_type ) {
$single_section_id = 'section-edd-single';
} else {
$single_section_id = 'single-posttype-' . $current_post_type;
}
$margin_option = 'post' === $current_post_type ? 'single-post-outside-spacing' : $single_section_id . '-margin';
$padding_option = 'post' === $current_post_type ? 'single-post-inside-spacing' : $single_section_id . '-padding';
$padding = astra_get_option( $padding_option );
$margin = astra_get_option( $margin_option );
$margin_selector = '.site .site-content #primary';
$padding_selector = '.site .site-content #primary .ast-article-single, .ast-separate-container .site-content #secondary .widget';
if ( class_exists( 'WooCommerce' ) && 'product' === $current_post_type ) {
$padding_selector = '.site .site-content #primary .ast-woocommerce-container';
}
// Desktop CSS.
$css_output_desktop = array(
$margin_selector => array(
// Margin CSS.
'margin-top' => astra_responsive_spacing( $margin, 'top', 'desktop' ),
'margin-bottom' => astra_responsive_spacing( $margin, 'bottom', 'desktop' ),
'margin-left' => astra_responsive_spacing( $margin, 'left', 'desktop' ),
'margin-right' => astra_responsive_spacing( $margin, 'right', 'desktop' ),
),
$padding_selector => array(
// Padding CSS.
'padding-top' => astra_responsive_spacing( $padding, 'top', 'desktop' ),
'padding-bottom' => astra_responsive_spacing( $padding, 'bottom', 'desktop' ),
'padding-left' => astra_responsive_spacing( $padding, 'left', 'desktop' ),
'padding-right' => astra_responsive_spacing( $padding, 'right', 'desktop' ),
),
);
// Tablet CSS.
$css_output_tablet = array(
$margin_selector => array(
// Margin CSS.
'margin-top' => astra_responsive_spacing( $margin, 'top', 'tablet' ),
'margin-bottom' => astra_responsive_spacing( $margin, 'bottom', 'tablet' ),
'margin-left' => astra_responsive_spacing( $margin, 'left', 'tablet' ),
'margin-right' => astra_responsive_spacing( $margin, 'right', 'tablet' ),
),
$padding_selector => array(
// Padding CSS.
'padding-top' => astra_responsive_spacing( $padding, 'top', 'tablet' ),
'padding-bottom' => astra_responsive_spacing( $padding, 'bottom', 'tablet' ),
'padding-left' => astra_responsive_spacing( $padding, 'left', 'tablet' ),
'padding-right' => astra_responsive_spacing( $padding, 'right', 'tablet' ),
),
);
// Mobile CSS.
$css_output_mobile = array(
$margin_selector => array(
// Margin CSS.
'margin-top' => astra_responsive_spacing( $margin, 'top', 'mobile' ),
'margin-bottom' => astra_responsive_spacing( $margin, 'bottom', 'mobile' ),
'margin-left' => astra_responsive_spacing( $margin, 'left', 'mobile' ),
'margin-right' => astra_responsive_spacing( $margin, 'right', 'mobile' ),
),
$padding_selector => array(
// Padding CSS.
'padding-top' => astra_responsive_spacing( $padding, 'top', 'mobile' ),
'padding-bottom' => astra_responsive_spacing( $padding, 'bottom', 'mobile' ),
'padding-left' => astra_responsive_spacing( $padding, 'left', 'mobile' ),
'padding-right' => astra_responsive_spacing( $padding, 'right', 'mobile' ),
),
);
$css_output = astra_parse_css( $css_output_desktop );
$css_output .= astra_parse_css( $css_output_tablet, '', astra_get_tablet_breakpoint() );
$css_output .= astra_parse_css( $css_output_mobile, '', astra_get_mobile_breakpoint() );
$dynamic_css .= $css_output;
if ( false === astra_get_option( 'ast-single-' . $current_post_type . '-title', ( class_exists( 'WooCommerce' ) && 'product' === $current_post_type ) ? false : true ) ) {
return $dynamic_css;
}
$layout_type = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-layout', 'layout-1' );
$layout_2_active = ( 'layout-2' === $layout_type ) ? true : false;
$exclude_attr = astra_get_option( 'enable-related-posts', false ) ? ':not(.related-entry-header)' : '';
if ( $layout_2_active ) {
$selector = '.ast-single-entry-banner[data-post-type="' . $current_post_type . '"]';
} else {
$selector = 'header.entry-header' . $exclude_attr;
}
$site_content_width = astra_get_option( 'site-content-width', 1200 );
$horz_alignment = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-horizontal-alignment' );
$desk_h_alignment = ( isset( $horz_alignment['desktop'] ) ) ? $horz_alignment['desktop'] : '';
$tab_h_alignment = ( isset( $horz_alignment['tablet'] ) ) ? $horz_alignment['tablet'] : '';
$mob_h_alignment = ( isset( $horz_alignment['mobile'] ) ) ? $horz_alignment['mobile'] : '';
$banner_padding = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-padding', Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-padding' ) );
$banner_margin = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-margin' );
$text_color = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-text-color' );
$title_color = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-title-color' );
$link_color = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-link-color' );
$link_hover_color = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-link-hover-color' );
$elements_gap = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-elements-gap', 10 );
$banner_height = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-height' );
$desk_banner_height = ( $layout_2_active && isset( $banner_height['desktop'] ) ) ? astra_get_css_value( $banner_height['desktop'], 'px' ) : '';
$tab_banner_height = ( $layout_2_active && isset( $banner_height['tablet'] ) ) ? astra_get_css_value( $banner_height['tablet'], 'px' ) : '';
$mob_banner_height = ( $layout_2_active && isset( $banner_height['mobile'] ) ) ? astra_get_css_value( $banner_height['mobile'], 'px' ) : '';
$vert_alignment = ( $layout_2_active ) ? astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-vertical-alignment', 'center' ) : 'center';
$width_type = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-width-type', 'fullwidth' );
$custom_width = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-custom-width', 1200 );
$single_structure = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-structure', 'page' === $current_post_type ? array( 'ast-dynamic-single-' . $current_post_type . '-image', 'ast-dynamic-single-' . $current_post_type . '-title' ) : array( 'ast-dynamic-single-' . $current_post_type . '-title', 'ast-dynamic-single-' . $current_post_type . '-meta' ) );
// Banner Text typography dynamic stylings.
$banner_text_font_size = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-text-font-size' );
// Banner Title typography dynamic stylings.
$banner_title_font_size = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-title-font-size', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-size' ) );
// Banner Meta typography dynamic stylings.
$banner_meta_font_size = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-meta-font-size' );
$css_output_min_tablet = array();
$narrow_container_width = astra_get_option( 'narrow-container-max-width', apply_filters( 'astra_narrow_container_width', 750 ) );
$author_avatar_size = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-author-avatar-size' );
// Aspect ratio.
$aspect_ratio_type = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-article-featured-image-ratio-type', 'predefined' );
$predefined_scale = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-article-featured-image-ratio-pre-scale', '16/9' );
$custom_scale_width = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-article-featured-image-custom-scale-width', 16 );
$custom_scale_height = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-article-featured-image-custom-scale-height', 9 );
$aspect_ratio = astra_get_dynamic_image_aspect_ratio( $aspect_ratio_type, $predefined_scale, $custom_scale_width, $custom_scale_height );
$object_fit_style = 'custom' === $aspect_ratio_type ? 'cover' : '';
// Remove featured image padding.
$remove_featured_image_padding = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-remove-featured-padding', false ) && 'layout-1' === $layout_type && 'none' === astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-article-featured-image-position-layout-1' ) ? true : false;
// Few settings from banner section are also applicable to 'layout-1' so adding this condition & compatibility.
if ( 'layout-1' === $layout_type ) {
$image_wrap_alignment = Astra_Dynamic_CSS::astra_4_4_0_compatibility() ? 'center' : '';
/**
* Desktop CSS.
*/
$css_output_desktop = array(
$selector => array(
'text-align' => $desk_h_alignment,
),
$selector . ' *' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-text-font-family' ), astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-text-font-weight' ), $banner_text_font_size, 'ast-dynamic-single-' . $current_post_type . '-text-font-extras', $text_color ),
$selector . ' .entry-title' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-title-font-family' ), astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-title-font-weight', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-weight' ) ), $banner_title_font_size, 'ast-dynamic-single-' . $current_post_type . '-title-font-extras', $title_color ),
$selector . ' .entry-meta, ' . $selector . ' .entry-meta *' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-meta-font-family' ), astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-meta-font-weight' ), $banner_meta_font_size, 'ast-dynamic-single-' . $current_post_type . '-meta-font-extras' ),
$selector . ' a, ' . $selector . ' a *' => array(
'color' => esc_attr( $link_color ),
),
$selector . ' a:hover, ' . $selector . ' a:hover *' => array(
'color' => esc_attr( $link_hover_color ),
),
$selector . ' > *:not(:last-child)' => array(
'margin-bottom' => $elements_gap . 'px',
),
$selector . ' .post-thumb-img-content' => array(
'text-align' => $image_wrap_alignment,
),
$selector . ' .post-thumb img, .ast-single-post-featured-section.post-thumb img' => array(
'aspect-ratio' => $aspect_ratio,
'width' => Astra_Dynamic_CSS::astra_4_6_0_compatibility() && 'default' !== $aspect_ratio_type ? '100%' : '',
'height' => Astra_Dynamic_CSS::astra_4_6_0_compatibility() && 'default' !== $aspect_ratio_type ? '100%' : '',
'object-fit' => $object_fit_style,
),
);
/**
* Tablet CSS.
*/
$css_output_tablet = array(
$selector => array(
'text-align' => $tab_h_alignment,
),
$selector . ' .entry-title' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'tablet' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'tablet' ),
),
$selector . ' .entry-meta, ' . $selector . ' .entry-meta *' => array(
'font-size' => astra_responsive_font( $banner_meta_font_size, 'tablet' ),
),
);
/**
* Mobile CSS.
*/
$css_output_mobile = array(
$selector => array(
'text-align' => $mob_h_alignment,
),
$selector . ' .entry-title' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'mobile' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'mobile' ),
),
$selector . ' .entry-meta, ' . $selector . ' .entry-meta *' => array(
'font-size' => astra_responsive_font( $banner_meta_font_size, 'mobile' ),
),
);
if ( $remove_featured_image_padding ) {
$single_post_container_spacing = astra_get_option( 'single-post-inside-spacing' );
$container_padding_defaults = Astra_Dynamic_CSS::astra_4_6_0_compatibility() && is_single() ? '2.5em' : '3em';
$container_lg_horz_spacing = ( true === astra_check_is_structural_setup() ) ? $container_padding_defaults : '6.67';
$container_lg_vert_spacing = ( true === astra_check_is_structural_setup() ) ? $container_padding_defaults : '5.34';
$astra_desktop_container_left_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'left', 'desktop' ) ? astra_responsive_spacing( $single_post_container_spacing, 'left', 'desktop', $container_lg_horz_spacing ) : 'var(--ast-container-default-xlg-padding)';
$astra_desktop_container_right_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'right', 'desktop' ) ? astra_responsive_spacing( $single_post_container_spacing, 'right', 'desktop', $container_lg_horz_spacing ) : 'var(--ast-container-default-xlg-padding)';
$astra_desktop_container_top_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'right', 'desktop' ) ? astra_responsive_spacing( $single_post_container_spacing, 'right', 'desktop', $container_lg_vert_spacing ) : 'var(--ast-container-default-xlg-padding)';
$astra_tablet_container_left_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'left', 'tablet' ) ? astra_responsive_spacing( $single_post_container_spacing, 'left', 'tablet', $container_lg_horz_spacing ) : 'var(--ast-container-default-xlg-padding)';
$astra_tablet_container_right_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'right', 'tablet' ) ? astra_responsive_spacing( $single_post_container_spacing, 'right', 'tablet', $container_lg_horz_spacing ) : 'var(--ast-container-default-xlg-padding)';
$astra_tablet_container_top_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'right', 'tablet' ) ? astra_responsive_spacing( $single_post_container_spacing, 'right', 'tablet', $container_lg_vert_spacing ) : 'var(--ast-container-default-xlg-padding)';
$astra_mobile_container_left_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'left', 'mobile' ) ? astra_responsive_spacing( $single_post_container_spacing, 'left', 'mobile', $container_lg_horz_spacing ) : '1em';
$astra_mobile_container_right_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'right', 'mobile' ) ? astra_responsive_spacing( $single_post_container_spacing, 'right', 'mobile', $container_lg_horz_spacing ) : '1em';
$astra_mobile_container_top_spacing = defined( 'ASTRA_EXT_VER' ) && astra_responsive_spacing( $single_post_container_spacing, 'right', 'mobile' ) ? astra_responsive_spacing( $single_post_container_spacing, 'right', 'mobile', $container_lg_vert_spacing ) : '1.5em';
$css_output_desktop[ '.ast-separate-container ' . $selector . ' .post-thumb' ]['margin-left'] = $astra_desktop_container_left_spacing ? 'calc( -1 * ' . $astra_desktop_container_left_spacing . ' )' : '';
$css_output_desktop[ '.ast-separate-container ' . $selector . ' > *:first-child.post-thumb' ]['margin-top'] = $astra_desktop_container_top_spacing ? 'calc( -1 * ' . $astra_desktop_container_top_spacing . ' )' : '';
$css_output_desktop[ '.ast-separate-container ' . $selector . ' .post-thumb' ]['margin-right'] = $astra_desktop_container_right_spacing ? 'calc( -1 * ' . $astra_desktop_container_right_spacing . ' )' : '';
$css_output_tablet[ '.ast-separate-container ' . $selector . ' .post-thumb' ]['margin-left'] = $astra_tablet_container_left_spacing ? 'calc( -1 * ' . $astra_tablet_container_left_spacing . ' )' : '';
$css_output_tablet[ '.ast-separate-container ' . $selector . ' > *:first-child.post-thumb' ]['margin-top'] = $astra_tablet_container_top_spacing ? 'calc( -1 * ' . $astra_tablet_container_top_spacing . ' )' : '';
$css_output_tablet[ '.ast-separate-container ' . $selector . ' .post-thumb' ]['margin-right'] = $astra_tablet_container_right_spacing ? 'calc( -1 * ' . $astra_tablet_container_right_spacing . ' )' : '';
$css_output_mobile[ '.ast-separate-container ' . $selector . ' .post-thumb' ]['margin-left'] = $astra_mobile_container_left_spacing ? 'calc( -1 * ' . $astra_mobile_container_left_spacing . ' )' : '';
$css_output_mobile[ '.ast-separate-container ' . $selector . ' > *:first-child.post-thumb' ]['margin-top'] = $astra_mobile_container_top_spacing ? 'calc( -1 * ' . $astra_mobile_container_top_spacing . ' )' : '';
$css_output_mobile[ '.ast-separate-container ' . $selector . ' .post-thumb' ]['margin-right'] = $astra_mobile_container_right_spacing ? 'calc( -1 * ' . $astra_mobile_container_right_spacing . ' )' : '';
}
} else {
$entry_title_selector = is_customize_preview() ? $selector . ' .ast-container .entry-title' : $selector . ' .entry-title';
$image_position = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-image-position', 'inside' );
$use_featured_background = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-featured-as-background', false );
$custom_background = astra_get_option(
'ast-dynamic-single-' . $current_post_type . '-banner-background',
Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-background' )
);
/**
* Desktop CSS.
*/
$css_output_desktop = array(
$selector => array(
'text-align' => $desk_h_alignment,
'justify-content' => $vert_alignment,
'min-height' => $desk_banner_height,
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'desktop' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'desktop' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'desktop' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'desktop' ),
'width' => '100%',
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'desktop' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'desktop' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'desktop' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'desktop' ),
),
$selector . '[data-banner-layout="layout-2"]' => astra_get_responsive_background_obj( $custom_background, 'desktop' ),
$selector . ' .ast-container *' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-text-font-family' ), astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-text-font-weight' ), $banner_text_font_size, 'ast-dynamic-single-' . $current_post_type . '-text-font-extras', $text_color ),
$selector . ' .ast-container > *:not(:last-child), ' . $selector . ' .read-more' => array(
'margin-bottom' => $elements_gap . 'px',
),
$selector . ' .ast-container' => array(
'width' => '100%',
),
$entry_title_selector => astra_get_font_array_css( astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-title-font-family' ), astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-title-font-weight', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-weight' ) ), $banner_title_font_size, 'ast-dynamic-single-' . $current_post_type . '-title-font-extras', $title_color ),
$selector . ' > .entry-title' => array(
'margin-bottom' => '0',
),
$selector . ' .entry-meta, ' . $selector . ' .entry-meta *' => astra_get_font_array_css( astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-meta-font-family' ), astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-meta-font-weight' ), $banner_meta_font_size, 'ast-dynamic-single-' . $current_post_type . '-meta-font-extras' ),
$selector . ' .ast-container a, ' . $selector . ' .ast-container a *' => array(
'color' => esc_attr( $link_color ),
),
$selector . ' .ast-container a:hover, ' . $selector . ' .ast-container a:hover *' => array(
'color' => esc_attr( $link_hover_color ),
),
'.ast-single-entry-banner .read-more .ast-button' => array(
'margin-top' => '0.5em',
'display' => 'inline-block',
),
$selector . ' .post-thumb img, .ast-single-post-featured-section img' => array(
'aspect-ratio' => $aspect_ratio,
'width' => Astra_Dynamic_CSS::astra_4_6_0_compatibility() && 'default' !== $aspect_ratio_type ? '100%' : '',
'height' => Astra_Dynamic_CSS::astra_4_6_0_compatibility() && 'default' !== $aspect_ratio_type ? '100%' : '',
'object-fit' => $object_fit_style,
),
$selector . ' .ast-container > *:last-child' => array(
'margin-bottom' => '0',
),
);
/**
* Min tablet width CSS.
*/
$css_output_min_tablet = array(
'.ast-narrow-container ' . $selector . ' .ast-container' => array(
'max-width' => $narrow_container_width . 'px',
'padding-left' => '0',
'padding-right' => '0',
),
);
/**
* Tablet CSS.
*/
$css_output_tablet = array(
$selector => array(
'text-align' => $tab_h_alignment,
'min-height' => $tab_banner_height,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'tablet' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'tablet' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'tablet' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'tablet' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'tablet' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'tablet' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'tablet' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'tablet' ),
),
$selector . '[data-banner-layout="layout-2"]' => astra_get_responsive_background_obj( $custom_background, 'tablet' ),
$selector . ' .entry-title' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'tablet' ),
),
$selector . ' .ast-container' => array(
'padding-left' => '0',
'padding-right' => '0',
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'tablet' ),
),
$selector . ' .entry-meta, ' . $selector . ' .entry-meta *' => array(
'font-size' => astra_responsive_font( $banner_meta_font_size, 'tablet' ),
),
);
/**
* Mobile CSS.
*/
$css_output_mobile = array(
$selector => array(
'text-align' => $mob_h_alignment,
'min-height' => $mob_banner_height,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'mobile' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'mobile' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'mobile' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'mobile' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'mobile' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'mobile' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'mobile' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'mobile' ),
),
$selector . '[data-banner-layout="layout-2"]' => astra_get_responsive_background_obj( $custom_background, 'mobile' ),
$selector . ' .entry-title' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'mobile' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'mobile' ),
),
$selector . ' .entry-meta, ' . $selector . ' .entry-meta *' => array(
'font-size' => astra_responsive_font( $banner_meta_font_size, 'mobile' ),
),
);
if ( ( $layout_2_active && 'custom' === $width_type ) || is_customize_preview() ) {
$css_output_desktop[ $selector . '[data-banner-width-type="custom"]' ]['max-width'] = $custom_width . 'px';
}
if ( 'outside' !== $image_position && in_array( 'ast-dynamic-single-' . $current_post_type . '-image', $single_structure ) && $use_featured_background ) {
/** @psalm-suppress PossiblyFalseArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$feat_image_src = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
/** @psalm-suppress PossiblyFalseArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
if ( $feat_image_src ) {
$css_output_desktop[ $selector . '[data-banner-background-type="featured"]' ] = array(
'background' => 'url( ' . esc_url( $feat_image_src ) . ' )',
'background-repeat' => 'no-repeat',
'background-attachment' => 'scroll',
'background-position' => 'center center',
'background-size' => 'cover',
);
$overlay_color = astra_get_option( 'ast-dynamic-single-' . $current_post_type . '-banner-featured-overlay', '' );
if ( '' !== $overlay_color && 'unset' !== $overlay_color ) {
$css_output_desktop[ $selector . '[data-banner-background-type="featured"]' ]['background'] = 'url( ' . esc_url( $feat_image_src ) . ' ) ' . $overlay_color;
$css_output_desktop[ $selector . '[data-banner-background-type="featured"]' ]['background-blend-mode'] = 'multiply';
}
}
}
if ( 'outside' === $image_position ) {
$css_output_desktop['.single article .post-thumb'] = array(
'margin-bottom' => '2em',
);
}
}
$dynamic_css .= '
.ast-single-entry-banner {
-js-display: flex;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
position: relative;
background: #eeeeee;
}
.ast-single-entry-banner[data-banner-layout="layout-1"] {
max-width: ' . astra_get_css_value( $site_content_width, 'px' ) . ';
background: inherit;
padding: 20px 0;
}
.ast-single-entry-banner[data-banner-width-type="custom"] {
margin: 0 auto;
width: 100%;
}
.ast-single-entry-banner + .site-content .entry-header {
margin-bottom: 0;
}
.site .ast-author-avatar {
--ast-author-avatar-size: ' . astra_get_css_value( $author_avatar_size, 'px' ) . ';
}
a.ast-underline-text {
text-decoration: underline;
}
.ast-container > .ast-terms-link {
position: relative;
display: block;
}
a.ast-button.ast-badge-tax {
padding: 4px 8px;
border-radius: 3px;
font-size: inherit;
}
';
if ( is_customize_preview() ) {
$dynamic_css .= '
.site-header-focus-item .ast-container div.customize-partial-edit-shortcut,
.site-header-focus-item .ast-container button.item-customizer-focus {
font-size: inherit;
}
';
}
$margin_top = astra_responsive_spacing( $margin, 'top', 'desktop' );
// To add top spacing for SureCart shop page default title.
if ( class_exists( 'SureCart' ) && $margin_top && 0 === intval( $margin_top ) && get_the_ID() === intval( get_option( 'surecart_shop_page_id' ) ) ) {
$dynamic_css .= '
.page .entry-header {
margin-top: 3em;
}
';
}
/* Parse CSS from array() */
$dynamic_css .= astra_parse_css( $css_output_desktop );
$dynamic_css .= astra_parse_css( $css_output_min_tablet, astra_get_tablet_breakpoint( '', 1 ) );
$dynamic_css .= astra_parse_css( $css_output_tablet, '', astra_get_tablet_breakpoint() );
$dynamic_css .= astra_parse_css( $css_output_mobile, '', astra_get_mobile_breakpoint() );
return $dynamic_css;
}

View File

@@ -0,0 +1,326 @@
<?php
/**
* Post Structures - Special Pages Dynamic CSS
*
* @package Astra
* @since 4.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Post Structures
*/
add_filter( 'astra_dynamic_theme_css', 'astra_special_archive_dynamic_css' );
/**
* Special Pages Dynamic CSS.
*
* @param string $dynamic_css Astra Dynamic CSS.
* @param string $dynamic_css_filtered Astra Dynamic CSS Filters.
* @return string Generated dynamic CSS for Post Structures.
*
* @since 4.6.0
*/
function astra_special_archive_dynamic_css( $dynamic_css, $dynamic_css_filtered = '' ) {
// Adding condition for search page only, once we have more special pages, we can modify this condition.
if ( ! is_search() ) {
return $dynamic_css;
}
foreach ( Astra_Posts_Structure_Loader::get_special_page_types() as $index => $special_type ) {
$title_section = 'section-' . $special_type . '-page-title';
$layout_type = astra_get_option( $title_section . '-layout', 'layout-1' );
$layout_2_active = ( 'layout-2' === $layout_type ) ? true : false;
if ( $layout_2_active ) {
$selector = '.search .ast-archive-entry-banner';
} else {
$selector = '.search .ast-archive-description';
}
$horizontal_alignment = astra_get_option( $title_section . '-horizontal-alignment' );
$desk_h_alignment = ( isset( $horizontal_alignment['desktop'] ) ) ? $horizontal_alignment['desktop'] : '';
$tab_h_alignment = ( isset( $horizontal_alignment['tablet'] ) ) ? $horizontal_alignment['tablet'] : '';
$mob_h_alignment = ( isset( $horizontal_alignment['mobile'] ) ) ? $horizontal_alignment['mobile'] : '';
if ( 'layout-1' === $layout_type ) {
$desk_h_alignment = ( '' !== $desk_h_alignment ) ? $desk_h_alignment : 'left';
$tab_h_alignment = ( '' !== $tab_h_alignment ) ? $tab_h_alignment : 'left';
$mob_h_alignment = ( '' !== $mob_h_alignment ) ? $mob_h_alignment : 'left';
}
$elements_gap = astra_get_option( $title_section . '-elements-gap', 10 );
$banner_padding = astra_get_option( $title_section . '-banner-padding', Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-padding' ) );
$banner_margin = astra_get_option( $title_section . '-banner-margin' );
$banner_height = astra_get_option( $title_section . '-banner-height' );
$desk_banner_height = ( $layout_2_active && isset( $banner_height['desktop'] ) ) ? astra_get_css_value( $banner_height['desktop'], 'px' ) : '';
$tab_banner_height = ( $layout_2_active && isset( $banner_height['tablet'] ) ) ? astra_get_css_value( $banner_height['tablet'], 'px' ) : '';
$mob_banner_height = ( $layout_2_active && isset( $banner_height['mobile'] ) ) ? astra_get_css_value( $banner_height['mobile'], 'px' ) : '';
$text_color = astra_get_option( $title_section . '-banner-text-color' );
$title_color = astra_get_option( $title_section . '-banner-title-color' );
$link_color = astra_get_option( $title_section . '-banner-link-color' );
$link_hover_color = astra_get_option( $title_section . '-banner-link-hover-color' );
$vert_alignment = ( $layout_2_active ) ? astra_get_option( $title_section . '-vertical-alignment', 'center' ) : 'center';
$width_type = astra_get_option( $title_section . '-banner-width-type', 'fullwidth' );
$custom_width = astra_get_option( $title_section . '-banner-custom-width', 1200 );
$background_type = astra_get_option( $title_section . '-banner-image-type', 'none' );
// Banner Text typography dynamic stylings.
$banner_text_font_size = astra_get_option( $title_section . '-text-font-size' );
// Banner Title typography dynamic stylings.
$banner_title_font_size = astra_get_option( $title_section . '-title-font-size', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-size' ) );
$css_output_min_tablet = array();
$narrow_container_width = astra_get_option( 'narrow-container-max-width', apply_filters( 'astra_narrow_container_width', 750 ) );
// Few settings from banner section are also applicable to 'layout-1' so adding this condition & compatibility.
if ( 'layout-1' === $layout_type ) {
$site_content_width = astra_get_option( 'site-content-width', 1200 );
/**
* Desktop CSS.
*/
$css_output_desktop = array(
$selector => array(
'max-width' => $site_content_width . 'px',
'width' => '100%',
'text-align' => $desk_h_alignment,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'desktop' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'desktop' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'desktop' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'desktop' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'desktop' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'desktop' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'desktop' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'desktop' ),
),
$selector . ' *' => astra_get_font_array_css( astra_get_option( $title_section . '-text-font-family' ), astra_get_option( $title_section . '-text-font-weight' ), $banner_text_font_size, $title_section . '-text-font-extras', $text_color ),
$selector . ' h1, ' . $selector . ' h1 *' => astra_get_font_array_css( astra_get_option( $title_section . '-title-font-family' ), astra_get_option( $title_section . '-title-font-weight', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-weight' ) ), $banner_title_font_size, $title_section . '-title-font-extras', $title_color ),
$selector . ' a, ' . $selector . ' a *' => array(
'color' => esc_attr( $link_color ),
),
$selector . ' a:hover, ' . $selector . ' a:hover *' => array(
'color' => esc_attr( $link_hover_color ),
),
$selector . ' > *:not(:last-child)' => array(
'margin-bottom' => $elements_gap . 'px',
),
);
/**
* Tablet CSS.
*/
$css_output_tablet = array(
$selector => array(
'text-align' => $tab_h_alignment,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'tablet' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'tablet' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'tablet' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'tablet' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'tablet' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'tablet' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'tablet' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'tablet' ),
),
$selector . ' h1' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'tablet' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'tablet' ),
),
);
/**
* Mobile CSS.
*/
$css_output_mobile = array(
$selector => array(
'text-align' => $mob_h_alignment,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'mobile' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'mobile' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'mobile' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'mobile' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'mobile' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'mobile' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'mobile' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'mobile' ),
),
$selector . ' h1' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'mobile' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'mobile' ),
),
);
if ( 'none' !== $background_type ) {
$custom_background = astra_get_option( $title_section . '-banner-custom-bg' );
$css_output_desktop['.search section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'desktop' );
$css_output_tablet['.search section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'tablet' );
$css_output_mobile['.search section.ast-archive-description'] = astra_get_responsive_background_obj( $custom_background, 'mobile' );
}
} else {
/**
* Desktop CSS.
*/
$css_output_desktop = array(
$selector => array(
'text-align' => $desk_h_alignment,
'justify-content' => $vert_alignment,
'min-height' => $desk_banner_height,
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'desktop' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'desktop' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'desktop' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'desktop' ),
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'desktop' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'desktop' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'desktop' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'desktop' ),
),
$selector . ' .ast-container' => array(
'width' => '100%',
),
$selector . ' .ast-container *' => astra_get_font_array_css( astra_get_option( $title_section . '-text-font-family' ), astra_get_option( $title_section . '-text-font-weight' ), $banner_text_font_size, $title_section . '-text-font-extras', $text_color ),
$selector . ' .ast-container h1, ' . $selector . ' .ast-container h1 *' => astra_get_font_array_css( astra_get_option( $title_section . '-title-font-family' ), astra_get_option( $title_section . '-title-font-weight', Astra_Posts_Structure_Loader::get_customizer_default( 'title-font-weight' ) ), $banner_title_font_size, $title_section . '-title-font-extras', $title_color ),
$selector . ' .ast-container h1' => array(
'margin-bottom' => '0',
),
'.ast-page-builder-template ' . $selector . ' .ast-container' => array(
'max-width' => '100%',
),
'.ast-narrow-container ' . $selector . ' .ast-container' => array(
'max-width' => $narrow_container_width . 'px',
),
$selector . ' .ast-container a, ' . $selector . ' .ast-container a *' => array(
'color' => esc_attr( $link_color ),
),
$selector . ' .ast-container a:hover, ' . $selector . ' .ast-container a:hover *' => array(
'color' => esc_attr( $link_hover_color ),
),
$selector . ' .ast-container > *:not(:last-child)' => array(
'margin-bottom' => $elements_gap . 'px',
),
);
/**
* Min tablet width CSS.
*/
$css_output_min_tablet = array(
'.ast-narrow-container ' . $selector . ' .ast-container' => array(
'max-width' => $narrow_container_width . 'px',
'padding-left' => '0',
'padding-right' => '0',
),
);
/**
* Tablet CSS.
*/
$css_output_tablet = array(
$selector => array(
'text-align' => $tab_h_alignment,
'min-height' => $tab_banner_height,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'tablet' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'tablet' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'tablet' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'tablet' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'tablet' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'tablet' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'tablet' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'tablet' ),
),
$selector . ' .ast-container' => array(
'padding-left' => '0',
'padding-right' => '0',
),
$selector . ' .ast-container h1' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'tablet' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'tablet' ),
),
);
/**
* Mobile CSS.
*/
$css_output_mobile = array(
$selector => array(
'text-align' => $mob_h_alignment,
'min-height' => $mob_banner_height,
'padding-top' => astra_responsive_spacing( $banner_padding, 'top', 'mobile' ),
'padding-right' => astra_responsive_spacing( $banner_padding, 'right', 'mobile' ),
'padding-bottom' => astra_responsive_spacing( $banner_padding, 'bottom', 'mobile' ),
'padding-left' => astra_responsive_spacing( $banner_padding, 'left', 'mobile' ),
'margin-top' => astra_responsive_spacing( $banner_margin, 'top', 'mobile' ),
'margin-right' => astra_responsive_spacing( $banner_margin, 'right', 'mobile' ),
'margin-bottom' => astra_responsive_spacing( $banner_margin, 'bottom', 'mobile' ),
'margin-left' => astra_responsive_spacing( $banner_margin, 'left', 'mobile' ),
),
$selector . ' .ast-container h1' => array(
'font-size' => astra_responsive_font( $banner_title_font_size, 'mobile' ),
),
$selector . ' *' => array(
'font-size' => astra_responsive_font( $banner_text_font_size, 'mobile' ),
),
);
if ( ( 'custom' === $width_type ) ) {
$css_output_desktop[ $selector . '[data-banner-width-type="custom"]' ]['max-width'] = $custom_width . 'px';
}
if ( 'custom' === $background_type ) {
$custom_background = astra_get_option( $title_section . '-banner-custom-bg' );
$css_output_desktop[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'desktop' );
$css_output_tablet[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'tablet' );
$css_output_mobile[ $selector . '[data-banner-background-type="custom"]' ] = astra_get_responsive_background_obj( $custom_background, 'mobile' );
}
}
/* Parse CSS from array() */
$dynamic_css .= astra_parse_css( $css_output_desktop );
$dynamic_css .= astra_parse_css( $css_output_min_tablet, astra_get_tablet_breakpoint( '', 1 ) );
$dynamic_css .= astra_parse_css( $css_output_tablet, '', astra_get_tablet_breakpoint() );
$dynamic_css .= astra_parse_css( $css_output_mobile, '', astra_get_mobile_breakpoint() );
}
$dynamic_css .= '
.ast-archive-entry-banner {
-js-display: flex;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
position: relative;
background: #eeeeee;
}
.ast-archive-entry-banner[data-banner-width-type="custom"] {
margin: 0 auto;
width: 100%;
}
.ast-archive-entry-banner[data-banner-layout="layout-1"] {
background: inherit;
padding: 20px 0;
text-align: left;
}
';
if ( is_customize_preview() ) {
$dynamic_css .= '
.site-header-focus-item .ast-container div.customize-partial-edit-shortcut,
.site-header-focus-item .ast-container button.item-customizer-focus {
font-size: inherit;
}
';
}
return $dynamic_css;
}

View File

@@ -0,0 +1,816 @@
<?php
/**
* Posts Structures Options for special pages.
*
* 1. Search page.
*
* @package Astra
* @link https://www.brainstormforce.com
* @since Astra 4.6.0
*/
// Block direct access to the file.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Bail if Customizer config base class does not exist.
if ( ! class_exists( 'Astra_Customizer_Config_Base' ) ) {
return;
}
/**
* Register Posts Structures Customizer Configurations.
*
* @since 4.6.0
*/
class Astra_Posts_Special_Archive_Structures_Configs extends Astra_Customizer_Config_Base {
/**
* Register Posts Structures Customizer Configurations.
*
* @param array $configurations Astra Customizer Configurations.
* @param WP_Customize_Manager $wp_customize instance of WP_Customize_Manager.
* @since 4.6.0
* @return Array Astra Customizer Configurations with updated configurations.
*/
public function register_configuration( $configurations, $wp_customize ) {
$section = 'ast-section-search-page';
$blog_layout = array(
'blog-layout-4' => array(
'label' => __( 'Grid', 'astra' ),
'path' => "<svg width='100' height='70' viewBox='0 0 100 70' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z' fill='white'/><mask id='mask0_6276_48581' style='mask-type:alpha' maskUnits='userSpaceOnUse' x='10' y='10' width='80' height='60'><path d='M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z' fill='white'/></mask><g mask='url(#mask0_6276_48581)'><rect x='15.5918' y='13.4707' width='19.9844' height='10.4376' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M35.5762 27.359H15.5918V26.209H35.5762V27.359Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M35.5762 30.8082H15.5918V29.6582H35.5762V30.8082Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M35.5762 34.2574H15.5918V33.1074H35.5762V34.2574Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M29.3473 37.7086H15.5918V36.5586H29.3473V37.7086Z' fill='#E9EAEE'/><rect x='40.0957' y='13.4707' width='19.9844' height='10.4376' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M60.0801 27.359H40.0957V26.209H60.0801V27.359Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M60.0801 30.8082H40.0957V29.6582H60.0801V30.8082Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M60.0801 34.2574H40.0957V33.1074H60.0801V34.2574Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M53.8512 37.7086H40.0957V36.5586H53.8512V37.7086Z' fill='#E9EAEE'/><rect x='64.6016' y='13.4707' width='19.9844' height='10.4376' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.586 27.359H64.6016V26.209H84.586V27.359Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.586 30.8082H64.6016V29.6582H84.586V30.8082Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.586 34.2574H64.6016V33.1074H84.586V34.2574Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M78.3571 37.7086H64.6016V36.5586H78.3571V37.7086Z' fill='#E9EAEE'/><rect x='15.5918' y='42.293' width='19.9844' height='10.4376' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M35.5762 56.1812H15.5918V55.0312H35.5762V56.1812Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M35.5762 59.6305H15.5918V58.4805H35.5762V59.6305Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M35.5762 63.0797H15.5918V61.9297H35.5762V63.0797Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M29.3473 66.5309H15.5918V65.3809H29.3473V66.5309Z' fill='#E9EAEE'/><rect x='40.0957' y='42.293' width='19.9844' height='10.4376' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M60.0801 56.1812H40.0957V55.0312H60.0801V56.1812Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M60.0801 59.6305H40.0957V58.4805H60.0801V59.6305Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M60.0801 63.0797H40.0957V61.9297H60.0801V63.0797Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M53.8512 66.5309H40.0957V65.3809H53.8512V66.5309Z' fill='#E9EAEE'/><rect x='64.6016' y='42.293' width='19.9844' height='10.4376' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.586 56.1812H64.6016V55.0312H84.586V56.1812Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.586 59.6305H64.6016V58.4805H84.586V59.6305Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.586 63.0797H64.6016V61.9297H84.586V63.0797Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M78.3571 66.5309H64.6016V65.3809H78.3571V66.5309Z' fill='#E9EAEE'/></g></svg>",
),
'blog-layout-5' => array(
'label' => __( 'List', 'astra' ),
'path' => "<svg width='100' height='70' viewBox='0 0 100 70' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z' fill='white'/><mask id='mask0_6276_50311' style='mask-type:alpha' maskUnits='userSpaceOnUse' x='10' y='10' width='80' height='60'><path d='M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z' fill='white'/></mask><g mask='url(#mask0_6276_50311)'><rect x='15.0234' y='17.3984' width='15.4914' height='8.10886' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.933 22.5801H32.9238V21.2441H84.933V22.5801Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M40.5729 18.7325H32.9238V17.3965H40.5729V18.7325Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.9766 25.5098H32.9238V24.1738H84.9766V25.5098Z' fill='#E9EAEE'/><rect x='15.0234' y='29.7637' width='15.4914' height='8.10886' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.933 34.9454H32.9238V33.6094H84.933V34.9454Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M40.5729 31.0977H32.9238V29.7617H40.5729V31.0977Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.9766 37.875H32.9238V36.5391H84.9766V37.875Z' fill='#E9EAEE'/><rect x='15.0234' y='42.1289' width='15.4914' height='8.10886' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.933 47.3106H32.9238V45.9746H84.933V47.3106Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M40.5729 43.4629H32.9238V42.127H40.5729V43.4629Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.9766 50.2403H32.9238V48.9043H84.9766V50.2403Z' fill='#E9EAEE'/><rect x='15.0234' y='54.4941' width='15.4914' height='8.10886' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.933 59.6758H32.9238V58.3398H84.933V59.6758Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M40.5729 55.8282H32.9238V54.4922H40.5729V55.8282Z' fill='#E9EAEE'/><path fill-rule='evenodd' clip-rule='evenodd' d='M84.9766 62.6055H32.9238V61.2695H84.9766V62.6055Z' fill='#E9EAEE'/></g></svg>",
),
'blog-layout-6' => array(
'label' => __( 'Cover', 'astra' ),
'path' => "<svg width='100' height='70' viewBox='0 0 100 70' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z' fill='white'/><mask id='mask0_6276_50601' style='mask-type:alpha' maskUnits='userSpaceOnUse' x='10' y='10' width='80' height='60'><path d='M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z' fill='white'/></mask><g mask='url(#mask0_6276_50601)'><rect x='16.998' y='15.502' width='31.6954' height='23.1341' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M45.7202 31.1512H19.9492V29.2812H45.7202V31.1512Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M27.9492 25.7645H19.9492V23.8945H27.9492V25.7645Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M45.7418 35.2509H19.9492V33.3809H45.7418V35.2509Z' fill='white'/><rect x='51.3066' y='15.502' width='31.6954' height='23.1341' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M80.0288 31.1512H54.2578V29.2812H80.0288V31.1512Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M62.2578 25.7645H54.2578V23.8945H62.2578V25.7645Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M80.0504 35.2509H54.2578V33.3809H80.0504V35.2509Z' fill='white'/><rect x='16.998' y='41.3633' width='31.6954' height='23.1341' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M45.7202 57.0126H19.9492V55.1426H45.7202V57.0126Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M27.9492 51.6259H19.9492V49.7559H27.9492V51.6259Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M45.7418 61.1122H19.9492V59.2422H45.7418V61.1122Z' fill='white'/><rect x='51.3066' y='41.3633' width='31.6954' height='23.1341' fill='#DADDE2'/><path fill-rule='evenodd' clip-rule='evenodd' d='M80.0288 57.0126H54.2578V55.1426H80.0288V57.0126Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M62.2578 51.6259H54.2578V49.7559H62.2578V51.6259Z' fill='white'/><path fill-rule='evenodd' clip-rule='evenodd' d='M80.0504 61.1122H54.2578V59.2422H80.0504V61.1122Z' fill='white'/></g></svg>",
),
);
/** @psalm-suppress UndefinedClass */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$if_astra_addon = defined( 'ASTRA_EXT_VER' ) && Astra_Ext_Extension::is_active( 'blog-pro' );
/** @psalm-suppress UndefinedClass */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
foreach ( Astra_Posts_Structure_Loader::get_special_page_types() as $index => $special_type ) {
$section = 'ast-section-' . $special_type . '-page';
$title_section = 'section-' . $special_type . '-page-title';
$archive_structure_choices = array();
$archive_structure_choices[ $title_section . '-title' ] = array(
'clone' => false,
'is_parent' => true,
'main_index' => $title_section . '-title',
'clone_limit' => 2,
'title' => __( 'Heading', 'astra' ),
);
$archive_structure_choices[ $title_section . '-description' ] = array(
'clone' => false,
'is_parent' => true,
'main_index' => $title_section . '-description',
'clone_limit' => 2,
'title' => __( 'Subheading', 'astra' ),
);
$archive_structure_choices[ $title_section . '-breadcrumb' ] = __( 'Breadcrumb', 'astra' );
$_configs = array(
array(
'name' => $title_section . '-ast-context-tabs',
'section' => $title_section,
'type' => 'control',
'control' => 'ast-builder-header-control',
'priority' => 0,
'description' => '',
'context' => array(),
),
array(
'name' => $title_section,
'title' => ucfirst( $special_type ) . __( ' Page Title', 'astra' ),
'type' => 'section',
'section' => $section,
'panel' => '',
'priority' => 1,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-page-title]',
'type' => 'control',
'default' => astra_get_option( 'ast-' . $special_type . '-page-title', true ),
'control' => 'ast-section-toggle',
'section' => $section,
'priority' => 2,
'linked' => $title_section,
'linkText' => ucfirst( $special_type ) . __( ' Page Title', 'astra' ),
'divider' => array( 'ast_class' => 'ast-bottom-divider ast-bottom-section-divider' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-layout]',
'type' => 'control',
'control' => 'ast-radio-image',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_choices' ),
'section' => $title_section,
'default' => astra_get_option( $title_section . '-layout', 'layout-1' ),
'priority' => 5,
'context' => Astra_Builder_Helper::$general_tab,
'title' => __( 'Banner Layout', 'astra' ),
'divider' => array( 'ast_class' => 'ast-section-spacing ast-bottom-spacing' ),
'choices' => array(
'layout-1' => array(
'label' => __( 'Layout 1', 'astra' ),
'path' => Astra_Builder_UI_Controller::fetch_svg_icon( 'post-layout' ),
),
'layout-2' => array(
'label' => __( 'Layout 2', 'astra' ),
'path' => '<span class="ahfb-svg-iconset ast-inline-flex"><svg width="100" height="70" viewBox="0 0 100 70" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z" fill="white"></path> <mask id="' . esc_attr( $title_section ) . '-masking" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="10" y="10" width="80" height="60"> <path d="M10 12C10 10.8954 10.8954 10 12 10H88C89.1046 10 90 10.8954 90 12V70H10V12Z" fill="white"></path> </mask> <g mask="url(#' . esc_attr( $title_section ) . '-masking)"> <path d="M2 9H95V35H2V9Z" fill="#DADDE2"></path> </g> <path fill-rule="evenodd" clip-rule="evenodd" d="M83 58H16V56H83V58Z" fill="#E9EAEE"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M83 64H16V62H83V64Z" fill="#E9EAEE"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M61 21H41V19H61V21Z" fill="white"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M53.4 25H33V23H53.4V25Z" fill="white"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M67 25H54.76V23H67V25Z" fill="white"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M42.4783 29H40V28H42.4783V29Z" fill="white"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M50.7391 29H47.4348V28H50.7391V29Z" fill="white"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M46.6087 29H43.3044V28H46.6087V29Z" fill="white"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M54.8696 29H51.5652V28H54.8696V29Z" fill="white"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M59 29H55.6956V28H59V29Z" fill="white"></path> <rect x="16" y="40" width="67" height="12" fill="#E9EAEE"></rect> </svg></span>',
),
),
'contextual_sub_control' => true,
'input_attrs' => array(
'dependents' => array(
'layout-1' => array( $title_section . '-empty-layout-message', $title_section . '-article-featured-image-position-layout-1', $title_section . '-article-featured-image-width-type' ),
'layout-2' => array( $title_section . '-featured-as-background', $title_section . '-banner-featured-overlay', $title_section . '-image-position', $title_section . '-featured-help-notice', $title_section . '-article-featured-image-position-layout-2' ),
),
),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-width-type]',
'type' => 'control',
'control' => 'ast-selector',
'section' => $title_section,
'default' => astra_get_option( $title_section . '-banner-width-type', 'fullwidth' ),
'priority' => 10,
'title' => __( 'Container Width', 'astra' ),
'choices' => array(
'fullwidth' => __( 'Full Width', 'astra' ),
'custom' => __( 'Custom', 'astra' ),
),
'divider' => array( 'ast_class' => 'ast-top-divider ast-bottom-spacing' ),
'responsive' => false,
'renderAs' => 'text',
'context' => array(
Astra_Builder_Helper::$general_tab_config,
'relation' => 'AND',
array(
'setting' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-layout]',
'operator' => '===',
'value' => 'layout-2',
),
),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-custom-width]',
'type' => 'control',
'control' => 'ast-slider',
'section' => $title_section,
'transport' => 'postMessage',
'default' => astra_get_option( $title_section . '-banner-custom-width', 1200 ),
'context' => array(
Astra_Builder_Helper::$general_tab_config,
'relation' => 'AND',
array(
'setting' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-layout]',
'operator' => '===',
'value' => 'layout-2',
),
array(
'setting' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-width-type]',
'operator' => '===',
'value' => 'custom',
),
),
'priority' => 15,
'title' => __( 'Custom Width', 'astra' ),
'suffix' => 'px',
'input_attrs' => array(
'min' => 768,
'step' => 1,
'max' => 1920,
),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-structure]',
'type' => 'control',
'control' => 'ast-sortable',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_multi_choices' ),
'section' => $title_section,
'context' => Astra_Builder_Helper::$general_tab,
'default' => astra_get_option( $title_section . '-structure' ),
'priority' => 20,
'title' => __( 'Structure', 'astra' ),
'divider' => array( 'ast_class' => 'ast-bottom-spacing' ),
'choices' => $archive_structure_choices,
),
array(
'name' => $title_section . '-custom-title',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-structure]',
'default' => astra_get_option( $title_section . '-custom-title' ),
'linked' => $title_section . '-title',
'type' => 'sub-control',
'control' => 'ast-text-input',
'settings' => array(),
'section' => $title_section,
'priority' => 1,
'title' => __( 'Text', 'astra' ),
),
array(
'name' => $title_section . '-found-custom-description',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-structure]',
'default' => astra_get_option( $title_section . '-found-custom-description' ),
'linked' => $title_section . '-description',
'type' => 'sub-control',
'control' => 'ast-text-input',
'input_attrs' => array(
'textarea' => true,
),
'section' => $title_section,
'priority' => 1,
'title' => __( 'When Results Found', 'astra' ),
),
array(
'name' => $title_section . '-not-found-custom-description',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-structure]',
'default' => astra_get_option( $title_section . '-not-found-custom-description' ),
'linked' => $title_section . '-description',
'type' => 'sub-control',
'control' => 'ast-text-input',
'input_attrs' => array(
'textarea' => true,
),
'section' => $title_section,
'priority' => 1,
'title' => __( 'When Results Not Found', 'astra' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-horizontal-alignment]',
'default' => astra_get_option( $title_section . '-horizontal-alignment' ),
'type' => 'control',
'control' => 'ast-selector',
'section' => $title_section,
'priority' => 21,
'title' => __( 'Horizontal Alignment', 'astra' ),
'context' => Astra_Builder_Helper::$general_tab,
'transport' => 'postMessage',
'choices' => array(
'left' => 'align-left',
'center' => 'align-center',
'right' => 'align-right',
),
'divider' => array( 'ast_class' => 'ast-top-divider' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-vertical-alignment]',
'default' => astra_get_option( $title_section . '-vertical-alignment', 'center' ),
'type' => 'control',
'control' => 'ast-selector',
'section' => $title_section,
'priority' => 22,
'title' => __( 'Vertical Alignment', 'astra' ),
'choices' => array(
'flex-start' => __( 'Top', 'astra' ),
'center' => __( 'Middle', 'astra' ),
'flex-end' => __( 'Bottom', 'astra' ),
),
'divider' => array( 'ast_class' => 'ast-top-divider ast-section-spacing' ),
'context' => array(
Astra_Builder_Helper::$general_tab_config,
'relation' => 'AND',
array(
'setting' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-layout]',
'operator' => '===',
'value' => 'layout-2',
),
),
'transport' => 'postMessage',
'renderAs' => 'text',
'responsive' => false,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-height]',
'type' => 'control',
'control' => 'ast-responsive-slider',
'section' => $title_section,
'transport' => 'postMessage',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_responsive_slider' ),
'default' => astra_get_option( $title_section . '-banner-height', Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-slider' ) ),
'context' => array(
Astra_Builder_Helper::$design_tab_config,
'relation' => 'AND',
array(
'setting' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-layout]',
'operator' => '===',
'value' => 'layout-2',
),
),
'priority' => 1,
'title' => __( 'Banner Min Height', 'astra' ),
'suffix' => 'px',
'input_attrs' => array(
'min' => 0,
'step' => 1,
'max' => 1000,
),
'divider' => array( 'ast_class' => 'ast-bottom-divider ast-section-spacing' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-elements-gap]',
'type' => 'control',
'control' => 'ast-slider',
'section' => $title_section,
'transport' => 'postMessage',
'default' => astra_get_option( $title_section . '-elements-gap', 10 ),
'context' => Astra_Builder_Helper::$design_tab,
'priority' => 5,
'title' => __( 'Inner Elements Spacing', 'astra' ),
'suffix' => 'px',
'input_attrs' => array(
'min' => 0,
'step' => 1,
'max' => 100,
),
'divider' => array( 'ast_class' => 'ast-bottom-divider ast-section-spacing' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-image-type]',
'type' => 'control',
'control' => 'ast-selector',
'section' => $title_section,
'default' => astra_get_option( $title_section . '-banner-image-type', 'none' ),
'priority' => 5,
'context' => Astra_Builder_Helper::$design_tab,
'title' => __( 'Container Background', 'astra' ),
'choices' => array(
'none' => __( 'None', 'astra' ),
'custom' => __( 'Custom', 'astra' ),
),
'divider' => array( 'ast_class' => 'ast-section-spacing ast-bottom-spacing' ),
'responsive' => false,
'renderAs' => 'text',
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-custom-bg]',
'default' => astra_get_option( $title_section . '-banner-custom-bg', Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-background' ) ),
'type' => 'control',
'control' => 'ast-responsive-background',
'section' => $title_section,
'title' => __( 'Background', 'astra' ),
'transport' => 'postMessage',
'priority' => 5,
'context' => array(
Astra_Builder_Helper::$design_tab_config,
'relation' => 'AND',
array(
'setting' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-image-type]',
'operator' => '===',
'value' => 'custom',
),
),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-title-color]',
'type' => 'control',
'control' => 'ast-color',
'section' => $title_section,
'default' => astra_get_option( $title_section . '-banner-title-color' ),
'transport' => 'postMessage',
'priority' => 9,
'title' => __( 'Title Color', 'astra' ),
'divider' => array( 'ast_class' => 'ast-top-divider ast-top-spacing' ),
'context' => Astra_Builder_Helper::$design_tab,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-text-color]',
'type' => 'control',
'control' => 'ast-color',
'section' => $title_section,
'default' => astra_get_option( $title_section . '-banner-text-color' ),
'priority' => 10,
'title' => __( 'Text Color', 'astra' ),
'transport' => 'postMessage',
'context' => Astra_Builder_Helper::$design_tab,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-link-color]',
'type' => 'control',
'control' => 'ast-color',
'section' => $title_section,
'default' => astra_get_option( $title_section . '-banner-link-color' ),
'transport' => 'postMessage',
'priority' => 15,
'title' => __( 'Link Color', 'astra' ),
'context' => Astra_Builder_Helper::$design_tab,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-link-hover-color]',
'type' => 'control',
'control' => 'ast-color',
'section' => $title_section,
'default' => astra_get_option( $title_section . '-banner-link-hover-color' ),
'transport' => 'postMessage',
'priority' => 20,
'title' => __( 'Link Hover Color', 'astra' ),
'context' => Astra_Builder_Helper::$design_tab,
'divider' => array( 'ast_class' => 'ast-bottom-spacing' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-title-typography-group]',
'type' => 'control',
'priority' => 22,
'control' => 'ast-settings-group',
'context' => array(
Astra_Builder_Helper::$design_tab_config,
'relation' => 'AND',
array(
'setting' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-structure]',
'operator' => 'contains',
'value' => $title_section . '-title',
),
),
'divider' => array( 'ast_class' => 'ast-top-divider' ),
'title' => __( 'Title Font', 'astra' ),
'section' => $title_section,
'transport' => 'postMessage',
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-text-typography-group]',
'type' => 'control',
'priority' => 25,
'control' => 'ast-settings-group',
'context' => Astra_Builder_Helper::$design_tab,
'title' => __( 'Text Font', 'astra' ),
'divider' => array( 'ast_class' => 'ast-bottom-spacing' ),
'section' => $title_section,
'transport' => 'postMessage',
),
array(
'name' => $title_section . '-text-font-family',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-text-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-font',
'font_type' => 'ast-font-family',
'default' => astra_get_option( $title_section . '-text-font-family', 'inherit' ),
'title' => __( 'Font Family', 'astra' ),
'connect' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-text-font-weight]',
'divider' => array( 'ast_class' => 'ast-sub-bottom-dotted-divider' ),
),
array(
'name' => $title_section . '-text-font-weight',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-text-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-font',
'font_type' => 'ast-font-weight',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_font_weight' ),
'default' => astra_get_option( $title_section . '-text-font-weight', 'inherit' ),
'title' => __( 'Font Weight', 'astra' ),
'connect' => $title_section . '-text-font-family',
'divider' => array( 'ast_class' => 'ast-sub-bottom-dotted-divider' ),
),
array(
'name' => $title_section . '-text-font-size',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-text-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-responsive-slider',
'default' => astra_get_option( $title_section . '-text-font-size', Astra_Posts_Structure_Loader::get_customizer_default( 'font-size' ) ),
'transport' => 'postMessage',
'title' => __( 'Font Size', 'astra' ),
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_responsive_slider' ),
'suffix' => array( 'px', 'em', 'vw', 'rem' ),
'input_attrs' => array(
'px' => array(
'min' => 0,
'step' => 1,
'max' => 200,
),
'em' => array(
'min' => 0,
'step' => 1,
'max' => 20,
),
'vw' => array(
'min' => 0,
'step' => 0.1,
'max' => 25,
),
'rem' => array(
'min' => 0,
'step' => 0.1,
'max' => 20,
),
),
),
array(
'name' => $title_section . '-text-font-extras',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-text-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-font-extras',
'default' => astra_get_option( $title_section . '-text-font-extras', Astra_Posts_Structure_Loader::get_customizer_default( 'font-extras' ) ),
'title' => __( 'Font Extras', 'astra' ),
),
array(
'name' => $title_section . '-title-font-family',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-title-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-font',
'font_type' => 'ast-font-family',
'default' => astra_get_option( $title_section . '-title-font-family', 'inherit' ),
'title' => __( 'Font Family', 'astra' ),
'connect' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-title-font-weight]',
'divider' => array( 'ast_class' => 'ast-sub-bottom-dotted-divider' ),
),
array(
'name' => $title_section . '-title-font-weight',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-title-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-font',
'font_type' => 'ast-font-weight',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_font_weight' ),
'default' => astra_get_option( $title_section . '-title-font-weight' ),
'title' => __( 'Font Weight', 'astra' ),
'connect' => $title_section . '-title-font-family',
'divider' => array( 'ast_class' => 'ast-sub-bottom-dotted-divider' ),
),
array(
'name' => $title_section . '-title-font-size',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-title-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-responsive-slider',
'default' => astra_get_option( $title_section . '-title-font-size' ),
'transport' => 'postMessage',
'title' => __( 'Font Size', 'astra' ),
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_responsive_slider' ),
'suffix' => array( 'px', 'em', 'vw', 'rem' ),
'input_attrs' => array(
'px' => array(
'min' => 0,
'step' => 1,
'max' => 200,
),
'em' => array(
'min' => 0,
'step' => 1,
'max' => 20,
),
'vw' => array(
'min' => 0,
'step' => 0.1,
'max' => 25,
),
'rem' => array(
'min' => 0,
'step' => 0.1,
'max' => 20,
),
),
),
array(
'name' => $title_section . '-title-font-extras',
'parent' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-title-typography-group]',
'section' => $title_section,
'type' => 'sub-control',
'control' => 'ast-font-extras',
'default' => astra_get_option( $title_section . '-title-font-extras', Astra_Posts_Structure_Loader::get_customizer_default( 'font-extras' ) ),
'title' => __( 'Font Extras', 'astra' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-margin]',
'default' => astra_get_option( $title_section . '-banner-margin', Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-spacing' ) ),
'type' => 'control',
'control' => 'ast-responsive-spacing',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_responsive_spacing' ),
'section' => $title_section,
'divider' => array( 'ast_class' => 'ast-top-divider' ),
'title' => __( 'Margin', 'astra' ),
'linked_choices' => true,
'transport' => 'postMessage',
'unit_choices' => array( 'px', 'em', '%' ),
'choices' => array(
'top' => __( 'Top', 'astra' ),
'right' => __( 'Right', 'astra' ),
'bottom' => __( 'Bottom', 'astra' ),
'left' => __( 'Left', 'astra' ),
),
'context' => Astra_Builder_Helper::$design_tab,
'priority' => 100,
'connected' => false,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $title_section . '-banner-padding]',
'default' => astra_get_option( $title_section . '-banner-padding', Astra_Posts_Structure_Loader::get_customizer_default( 'responsive-padding' ) ),
'type' => 'control',
'control' => 'ast-responsive-spacing',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_responsive_spacing' ),
'section' => $title_section,
'title' => __( 'Padding', 'astra' ),
'linked_choices' => true,
'transport' => 'postMessage',
'unit_choices' => array( 'px', 'em', '%' ),
'choices' => array(
'top' => __( 'Top', 'astra' ),
'right' => __( 'Right', 'astra' ),
'bottom' => __( 'Bottom', 'astra' ),
'left' => __( 'Left', 'astra' ),
),
'context' => Astra_Builder_Helper::$design_tab,
'priority' => 120,
'connected' => false,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-content-layout]',
'type' => 'control',
'control' => 'ast-radio-image',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_choices' ),
'section' => $section,
'default' => astra_get_option( 'ast-' . $special_type . '-content-layout', 'default' ),
'priority' => 3,
'title' => __( 'Container Layout', 'astra' ),
'choices' => array(
'default' => array(
'label' => __( 'Default', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'layout-default', false ) : '',
),
'normal-width-container' => array(
'label' => __( 'Normal', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'normal-width-container', false ) : '',
),
'narrow-width-container' => array(
'label' => __( 'Narrow', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'narrow-width-container', false ) : '',
),
'full-width-container' => array(
'label' => __( 'Full Width', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'full-width-container', false ) : '',
),
),
'divider' => array( 'ast_class' => 'ast-top-divider ast-bottom-spacing' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-content-style]',
'type' => 'control',
'control' => 'ast-selector',
'section' => $section,
'default' => astra_get_option( 'ast-' . $special_type . '-content-style', 'default' ),
'priority' => 3,
'title' => __( 'Container Style', 'astra' ),
'description' => __( 'Container style will apply only when layout is set to either normal or narrow.', 'astra' ),
'choices' => array(
'default' => __( 'Default', 'astra' ),
'unboxed' => __( 'Unboxed', 'astra' ),
'boxed' => __( 'Boxed', 'astra' ),
),
'renderAs' => 'text',
'responsive' => false,
'divider' => array( 'ast_class' => 'ast-top-dotted-divider' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-sidebar-layout]',
'type' => 'control',
'control' => 'ast-radio-image',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_choices' ),
'section' => $section,
'default' => astra_get_option( 'ast-' . $special_type . '-sidebar-layout', 'default' ),
'description' => __( 'Sidebar will only apply when container layout is set to normal.', 'astra' ),
'priority' => 3,
'title' => __( 'Sidebar Layout', 'astra' ),
'divider' => array( 'ast_class' => 'ast-top-section-divider' ),
'choices' => array(
'default' => array(
'label' => __( 'Default', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'layout-default', false ) : '',
),
'no-sidebar' => array(
'label' => __( 'No Sidebar', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'no-sidebar', false ) : '',
),
'left-sidebar' => array(
'label' => __( 'Left Sidebar', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'left-sidebar', false ) : '',
),
'right-sidebar' => array(
'label' => __( 'Right Sidebar', 'astra' ),
'path' => ( class_exists( 'Astra_Builder_UI_Controller' ) ) ? Astra_Builder_UI_Controller::fetch_svg_icon( 'right-sidebar', false ) : '',
),
),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-sidebar-style]',
'type' => 'control',
'control' => 'ast-selector',
'section' => $section,
'default' => astra_get_option( 'ast-' . $special_type . '-sidebar-style', 'default' ),
'priority' => 3,
'title' => __( 'Sidebar Style', 'astra' ),
'choices' => array(
'default' => __( 'Default', 'astra' ),
'unboxed' => __( 'Unboxed', 'astra' ),
'boxed' => __( 'Boxed', 'astra' ),
),
'responsive' => false,
'renderAs' => 'text',
'divider' => array( 'ast_class' => 'ast-top-divider' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-results-style]',
'type' => 'control',
'control' => 'ast-radio-image',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_choices' ),
'section' => $section,
'default' => astra_get_option( 'ast-' . $special_type . '-results-style' ),
'priority' => 14,
'divider' => array( 'ast_class' => 'ast-top-section-divider' ),
'title' => __( 'Results Layout', 'astra' ),
'choices' => $blog_layout,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-results-per-page]',
'default' => astra_get_option( 'ast-' . $special_type . '-results-per-page' ),
'type' => 'control',
'control' => 'ast-number',
'qty_selector' => true,
'section' => $section,
'title' => __( 'Post Per Page', 'astra' ),
'priority' => 14,
'responsive' => false,
'input_attrs' => array(
'min' => 1,
'step' => 1,
'max' => 500,
),
'divider' => array( 'ast_class' => 'ast-top-dotted-divider ast-bottom-section-divider' ),
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-live-search]',
'default' => astra_get_option( 'ast-' . $special_type . '-live-search' ),
'type' => 'control',
'control' => 'ast-toggle-control',
'section' => $section,
'description' => __( 'This option activates Live Search support for the search box on the no results page.', 'astra' ),
'title' => __( 'Live Search', 'astra' ),
'priority' => 15,
'context' => Astra_Builder_Helper::$general_tab,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-live-search-post-types]',
'default' => astra_get_option( 'ast-' . $special_type . '-live-search-post-types' ),
'type' => 'control',
'section' => $section,
'control' => 'ast-multi-selector',
'priority' => 15,
'title' => __( 'Search Within Post Types', 'astra' ),
'context' => array(
Astra_Builder_Helper::$general_tab_config,
array(
'setting' => ASTRA_THEME_SETTINGS . '[ast-' . $special_type . '-live-search]',
'operator' => '==',
'value' => true,
),
),
'transport' => 'refresh',
'choices' => astra_customizer_search_post_types_choices(),
'divider' => array( 'ast_class' => 'ast-top-dotted-divider' ),
'renderAs' => 'text',
'input_attrs' => array(
'stack_after' => 2, // Currently stack options supports after 2 & 3.
),
),
);
$configurations = array_merge( $configurations, $_configs );
}
return $configurations;
}
}
/**
* Kicking this off by creating new object.
*/
new Astra_Posts_Special_Archive_Structures_Configs();

View File

@@ -0,0 +1,140 @@
<?php
/**
* Posts Structures Options for our theme.
*
* @package Astra
* @link https://www.brainstormforce.com
* @since Astra 4.0.0
*/
// Block direct access to the file.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Bail if Customizer config base class does not exist.
if ( ! class_exists( 'Astra_Customizer_Config_Base' ) ) {
return;
}
/**
* Register Posts Structures Customizer Configurations.
*
* @since 4.0.0
*/
class Astra_Posts_Structures_Configs extends Astra_Customizer_Config_Base {
/**
* Excluding some post types with avoiding narrow-width container layout.
*
* @return array
* @since 4.0.0
*/
public static function get_narrow_width_exculde_cpts() {
$exclude_cpts = array();
if ( ( ! Astra_Dynamic_CSS::astra_fullwidth_sidebar_support() ) ) {
return apply_filters( 'astra_exculde_narrow_width_support_posttypes', array( 'product', 'download', 'course', 'lesson', 'tutor_quiz', 'tutor_assignments', 'sfwd-assignment', 'sfwd-essays', 'sfwd-transactions', 'sfwd-certificates', 'sfwd-quiz' ) );
}
// Excluded some more cpts for narrow.
return apply_filters( 'astra_exculde_narrow_width_support_posttypes', array( 'product', 'download', 'course', 'lesson', 'tutor_quiz', 'tutor_assignments', 'sfwd-assignment', 'sfwd-essays', 'sfwd-transactions', 'sfwd-certificates', 'sfwd-quiz', 'sfwd-courses', 'sfwd-lessons', 'sfwd-topic', 'groups' ) );
}
/**
* Function to get formatted dynamic cpt section title.
*
* @since 4.0.2
* @param object|null $post_type_obj WP_Post_Type object.
* @param string $label fallback label.
* @return string formatted label.
*/
public static function astra_get_dynamic_section_title( $post_type_obj, $label ) {
return is_object( $post_type_obj ) && isset( $post_type_obj->labels->name ) ? $post_type_obj->labels->name : ucfirst( $label );
}
/**
* Register Posts Structures Customizer Configurations.
*
* @param Array $configurations Astra Customizer Configurations.
* @param WP_Customize_Manager $wp_customize instance of WP_Customize_Manager.
* @since 4.0.0
* @return Array Astra Customizer Configurations with updated configurations.
*/
public function register_configuration( $configurations, $wp_customize ) {
$post_types = Astra_Posts_Structure_Loader::get_supported_post_types();
if ( ! empty( $post_types ) ) {
$_configs = array(
array(
'name' => 'section-posts-structure',
'type' => 'section',
'priority' => 69,
'title' => __( 'Custom Post Types', 'astra' ),
),
);
$ignore_single_for_posttypes = array( 'post', 'product' );
$ignore_archive_for_posttypes = array( 'post', 'product' );
/**
* Individual post types main section.
*/
foreach ( $post_types as $index => $label ) {
$post_type_object = get_post_type_object( $label );
$parent_section = 'section-posts-structure';
if ( 'download' === $label ) {
$parent_section = 'section-edd-group';
}
if ( 'llms_membership' === $label ) {
$parent_section = 'section-lifterlms';
}
if ( 'groups' === $label || 'sfwd-topic' === $label || 'sfwd-lessons' === $label || 'sfwd-courses' === $label ) {
$parent_section = 'section-learndash';
}
$section_title = self::astra_get_dynamic_section_title( $post_type_object, $label );
$_configs[] = array(
'name' => 'section-posttype-' . $label,
'type' => 'section',
'section' => $parent_section,
'title' => $section_title,
'priority' => 69,
);
if ( ! in_array( $label, $ignore_archive_for_posttypes ) ) {
$_configs[] = array(
'name' => 'archive-posttype-' . $label,
'type' => 'section',
'title' => __( 'Archive', 'astra' ) . ' ' . $section_title,
'section' => 'section-posttype-' . $label,
'priority' => 5,
);
}
if ( ! in_array( $label, $ignore_single_for_posttypes ) ) {
$_configs[] = array(
'name' => 'single-posttype-' . $label,
'type' => 'section',
'title' => __( 'Single', 'astra' ) . ' ' . $section_title,
'section' => 'section-posttype-' . $label,
'priority' => 10,
);
}
}
$configurations = array_merge( $configurations, $_configs );
}
return $configurations;
}
}
/**
* Kicking this off by creating new object.
*/
new Astra_Posts_Structures_Configs();

View File

@@ -0,0 +1,293 @@
<?php
/**
* Related Posts Loader for Astra theme.
*
* @package Astra
* @link https://www.brainstormforce.com
* @since Astra 3.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Customizer Initialization
*
* @since 3.5.0
*/
class Astra_Related_Posts_Loader {
/**
* Constructor
*
* @since 3.5.0
*/
public function __construct() {
add_filter( 'astra_theme_defaults', array( $this, 'theme_defaults' ) );
add_action( 'customize_register', array( $this, 'related_posts_customize_register' ), 2 );
// Load Google fonts.
add_action( 'astra_get_fonts', array( $this, 'add_fonts' ), 1 );
}
/**
* Enqueue google fonts.
*
* @return void
*/
public function add_fonts() {
if ( astra_target_rules_for_related_posts() ) {
// Related Posts Section title.
$section_title_font_family = astra_get_option( 'related-posts-section-title-font-family' );
$section_title_font_weight = astra_get_option( 'related-posts-section-title-font-weight' );
Astra_Fonts::add_font( $section_title_font_family, $section_title_font_weight );
// Related Posts - Posts title.
$post_title_font_family = astra_get_option( 'related-posts-title-font-family' );
$post_title_font_weight = astra_get_option( 'related-posts-title-font-weight' );
Astra_Fonts::add_font( $post_title_font_family, $post_title_font_weight );
// Related Posts - Meta Font.
$meta_font_family = astra_get_option( 'related-posts-meta-font-family' );
$meta_font_weight = astra_get_option( 'related-posts-meta-font-weight' );
Astra_Fonts::add_font( $meta_font_family, $meta_font_weight );
// Related Posts - Content Font.
$content_font_family = astra_get_option( 'related-posts-content-font-family' );
$content_font_weight = astra_get_option( 'related-posts-content-font-weight' );
Astra_Fonts::add_font( $content_font_family, $content_font_weight );
}
}
/**
* Set Options Default Values
*
* @param array $defaults Astra options default value array.
* @return array
*/
public function theme_defaults( $defaults ) {
/**
* Update Astra default color and typography values. To not update directly on existing users site, added backwards.
*
* @since 4.0.0
*/
$apply_new_default_color_typo_values = Astra_Dynamic_CSS::astra_check_default_color_typo();
$astra_options = Astra_Theme_Options::get_astra_options();
$astra_blog_update = Astra_Dynamic_CSS::astra_4_6_0_compatibility();
// Related Posts.
$defaults['enable-related-posts'] = false;
$defaults['related-posts-title'] = __( 'Related Posts', 'astra' );
$defaults['releted-posts-title-alignment'] = 'left';
$defaults['related-posts-total-count'] = 2;
$defaults['enable-related-posts-excerpt'] = false;
$defaults['related-posts-box-placement'] = 'default';
$defaults['related-posts-outside-location'] = 'above';
$defaults['related-posts-container-width'] = $astra_blog_update ? '' : 'fallback';
$defaults['related-posts-excerpt-count'] = 25;
$defaults['related-posts-based-on'] = 'categories';
$defaults['related-posts-order-by'] = 'date';
$defaults['related-posts-order'] = 'asc';
$defaults['related-posts-grid-responsive'] = array(
'desktop' => '2-equal',
'tablet' => '2-equal',
'mobile' => 'full',
);
$defaults['related-posts-structure'] = array(
'featured-image',
'title-meta',
);
$defaults['related-posts-tag-style'] = 'none';
$defaults['related-posts-category-style'] = 'none';
$defaults['related-posts-date-format'] = '';
$defaults['related-posts-meta-date-type'] = 'published';
$defaults['related-posts-author-avatar-size'] = '';
$defaults['related-posts-author-avatar'] = false;
$defaults['related-posts-author-prefix-label'] = astra_default_strings( 'string-blog-meta-author-by', false );
$defaults['related-posts-image-size'] = '';
$defaults['related-posts-image-custom-scale-width'] = 16;
$defaults['related-posts-image-custom-scale-height'] = 9;
$defaults['related-posts-image-ratio-pre-scale'] = '16/9';
$defaults['related-posts-image-ratio-type'] = '';
$defaults['related-posts-meta-structure'] = array(
'comments',
'category',
'author',
);
// Related Posts - Color styles.
$defaults['related-posts-text-color'] = $apply_new_default_color_typo_values ? 'var(--ast-global-color-2)' : '';
$defaults['related-posts-link-color'] = '';
$defaults['related-posts-title-color'] = $apply_new_default_color_typo_values ? 'var(--ast-global-color-2)' : '';
$defaults['related-posts-background-color'] = '';
$defaults['related-posts-meta-color'] = '';
$defaults['related-posts-link-hover-color'] = '';
$defaults['related-posts-meta-link-hover-color'] = '';
// Related Posts - Title typo.
$defaults['related-posts-section-title-font-family'] = 'inherit';
$defaults['related-posts-section-title-font-weight'] = 'inherit';
$defaults['related-posts-section-title-text-transform'] = '';
$defaults['related-posts-section-title-line-height'] = $apply_new_default_color_typo_values ? '1.25' : '';
$defaults['related-posts-section-title-font-extras'] = array(
'line-height' => ! isset( $astra_options['related-posts-section-title-font-extras'] ) && isset( $astra_options['related-posts-section-title-line-height'] ) ? $astra_options['related-posts-section-title-line-height'] : '1.6',
'line-height-unit' => 'em',
'letter-spacing' => '',
'letter-spacing-unit' => 'px',
'text-transform' => ! isset( $astra_options['related-posts-section-title-font-extras'] ) && isset( $astra_options['related-posts-section-title-text-transform'] ) ? $astra_options['related-posts-section-title-text-transform'] : '',
'text-decoration' => '',
);
$defaults['related-posts-section-title-font-size'] = array(
'desktop' => $apply_new_default_color_typo_values ? '26' : '30',
'tablet' => '',
'mobile' => '',
'desktop-unit' => 'px',
'tablet-unit' => 'px',
'mobile-unit' => 'px',
);
// Related Posts - Title typo.
$defaults['related-posts-title-font-family'] = 'inherit';
$defaults['related-posts-title-font-weight'] = $apply_new_default_color_typo_values ? '500' : 'inherit';
$defaults['related-posts-title-text-transform'] = '';
$defaults['related-posts-title-line-height'] = '1';
$defaults['related-posts-title-font-size'] = array(
'desktop' => '20',
'tablet' => '',
'mobile' => '',
'desktop-unit' => 'px',
'tablet-unit' => 'px',
'mobile-unit' => 'px',
);
$defaults['related-posts-title-font-extras'] = array(
'line-height' => ! isset( $astra_options['related-posts-title-font-extras'] ) && isset( $astra_options['related-posts-title-line-height'] ) ? $astra_options['related-posts-title-line-height'] : ( $astra_blog_update ? '1.5' : '1' ),
'line-height-unit' => 'em',
'letter-spacing' => '',
'letter-spacing-unit' => 'px',
'text-transform' => ! isset( $astra_options['related-posts-title-font-extras'] ) && isset( $astra_options['related-posts-title-text-transform'] ) ? $astra_options['related-posts-title-text-transform'] : '',
'text-decoration' => '',
);
// Related Posts - Meta typo.
$defaults['related-posts-meta-font-family'] = 'inherit';
$defaults['related-posts-meta-font-weight'] = 'inherit';
$defaults['related-posts-meta-text-transform'] = '';
$defaults['related-posts-meta-line-height'] = '';
$defaults['related-posts-meta-font-size'] = array(
'desktop' => '14',
'tablet' => '',
'mobile' => '',
'desktop-unit' => 'px',
'tablet-unit' => 'px',
'mobile-unit' => 'px',
);
$defaults['related-posts-meta-font-extras'] = array(
'line-height' => ! isset( $astra_options['related-posts-meta-font-extras'] ) && isset( $astra_options['related-posts-meta-line-height'] ) ? $astra_options['related-posts-meta-line-height'] : '1.6',
'line-height-unit' => 'em',
'letter-spacing' => '',
'letter-spacing-unit' => 'px',
'text-transform' => ! isset( $astra_options['related-posts-meta-font-extras'] ) && isset( $astra_options['related-posts-meta-text-transform'] ) ? $astra_options['related-posts-meta-text-transform'] : '',
'text-decoration' => '',
);
// Related Posts - Content typo.
$defaults['related-posts-content-font-family'] = 'inherit';
$defaults['related-posts-content-font-weight'] = 'inherit';
$defaults['related-posts-content-font-extras'] = array(
'line-height' => ! isset( $astra_options['related-posts-content-font-extras'] ) && isset( $astra_options['related-posts-content-line-height'] ) ? $astra_options['related-posts-content-line-height'] : '',
'line-height-unit' => 'em',
'letter-spacing' => '',
'letter-spacing-unit' => 'px',
'text-transform' => ! isset( $astra_options['related-posts-content-font-extras'] ) && isset( $astra_options['related-posts-content-text-transform'] ) ? $astra_options['related-posts-content-text-transform'] : '',
'text-decoration' => '',
);
$defaults['related-posts-content-font-size'] = array(
'desktop' => '',
'tablet' => '',
'mobile' => '',
'desktop-unit' => 'px',
'tablet-unit' => 'px',
'mobile-unit' => 'px',
);
$defaults['ast-sub-section-related-posts-padding'] = array(
'desktop' => array(
'top' => 2.5,
'right' => 2.5,
'bottom' => 2.5,
'left' => 2.5,
),
'tablet' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'mobile' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'desktop-unit' => 'em',
'tablet-unit' => 'em',
'mobile-unit' => 'em',
);
$defaults['ast-sub-section-related-posts-margin'] = array(
'desktop' => array(
'top' => 2,
'right' => '',
'bottom' => '',
'left' => '',
),
'tablet' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'mobile' => array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
),
'desktop-unit' => 'em',
'tablet-unit' => 'em',
'mobile-unit' => 'em',
);
return $defaults;
}
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*
* @since 3.5.0
*/
public function related_posts_customize_register( $wp_customize ) {
/**
* Register Config control in Related Posts.
*/
// @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
require_once ASTRA_RELATED_POSTS_DIR . 'customizer/class-astra-related-posts-configs.php';
// @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
}
/**
* Render the Related Posts title for the selective refresh partial.
*
* @since 3.5.0
*/
public function render_related_posts_title() {
return astra_get_option( 'related-posts-title' );
}
}
/**
* Kicking this off by creating NEW instace.
*/
new Astra_Related_Posts_Loader();

View File

@@ -0,0 +1,435 @@
<?php
/**
* Related Posts for Astra theme.
*
* @package Astra
* @link https://www.brainstormforce.com
* @since Astra 3.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Breadcrumbs Markup Initial Setup
*
* @since 3.5.0
*/
class Astra_Related_Posts_Markup {
/**
* Constructor
*/
public function __construct() {
add_action( 'astra_content_before', array( $this, 'initialize_related_posts' ) );
}
/**
* Initialize related posts module in Astra.
*
* @since 4.6.0
*/
public function initialize_related_posts() {
$priority = 10;
$location = astra_get_option( 'related-posts-outside-location' );
$module_placement = astra_get_option( 'related-posts-box-placement' );
if ( 'outside' === $module_placement ) {
$action = 'astra_content_after';
if ( astra_get_option( 'enable-comments-area', true ) && 'outside' === astra_get_option( 'comments-box-placement' ) ) {
$priority = 'below' === $location ? 20 : 9;
}
} elseif ( 'inside' === $module_placement ) {
$action = 'astra_entry_bottom';
$priority = 'below' === $location ? 20 : 10;
} else {
$action = 'astra_entry_after';
}
add_action( $action, array( $this, 'astra_related_posts_markup' ), $priority );
}
/**
* Enable/Disable Single Post -> Related Posts section.
*
* @since 3.5.0
* @return void
*/
public function astra_related_posts_markup() {
if ( astra_target_rules_for_related_posts() ) {
$this->astra_get_related_posts();
}
}
/**
* Related Posts markup.
*
* @since 3.5.0
* @return bool
*/
public function astra_get_related_posts() {
global $post;
$post_id = $post->ID;
$related_posts_title = astra_get_i18n_option( 'related-posts-title', _x( '%astra%', 'Single Blog/Post Related Posts: Title', 'astra' ) );
$related_post_meta = astra_get_option( 'related-posts-meta-structure' );
$related_post_structure = astra_get_option_meta( 'related-posts-structure' );
$exclude_ids = apply_filters( 'astra_related_posts_exclude_post_ids', array( $post_id ), $post_id );
$related_posts_total_count = absint( astra_get_option( 'related-posts-total-count', 2 ) );
$module_container_width = astra_get_option( 'related-posts-container-width' );
$module_container_width = 'inside' === astra_get_option( 'related-posts-box-placement' ) ? '' : 'ast-container--' . $module_container_width;
$related_category_style = astra_get_option( 'related-posts-category-style' );
$related_tag_style = astra_get_option( 'related-posts-tag-style' );
// Get related posts by WP_Query.
$query_posts = $this->astra_get_related_posts_by_query( $post_id );
if ( $query_posts ) {
if ( ! $query_posts->have_posts() ) {
return apply_filters( 'astra_related_posts_no_posts_avilable_message', '', $post_id );
}
// Added flag to load wrapper section 'ast-single-related-posts-container' only once, because as we removed 'posts__not_in' param from WP_Query and we conditionally handle posts__not_in below so it needs to verify if there are other posts as well to load, then only we will display wrapper.
$related_posts_section_loaded = false;
do_action( 'astra_related_posts_loop_before' );
/**
* WP_Query posts loop.
*
* Used $post_counter & ( $post_counter < $total_posts_count ) condition to manage posts in while loop because there is case where manual 'post__not_in' condition handling scenario fails within loop.
*
* # CASE EXAMPLE - If total posts set to 4 (where 'post__not_in' not used in WP_Query) so there is a chance that out of those 4 posts, 1 post will be currently active on frontend.
*
* So what will happen in this case - Within following loop the current post will exclude by if condition & only 3 posts will be shown up.
*
* To avoid such cases $post_counter & ( $post_counter < $total_posts_count ) condition used.
*
* @since 3.5.0
*/
$post_counter = 1;
$total_posts_count = $related_posts_total_count + 1;
while ( $query_posts->have_posts() && $post_counter < $total_posts_count ) {
$query_posts->the_post();
$post_id = get_the_ID();
$separator = astra_get_option( 'related-metadata-separator', '/' );
$output_str = astra_get_post_meta( $related_post_meta, $separator, 'related-posts' );
if ( is_array( $exclude_ids ) && ! in_array( $post_id, $exclude_ids ) ) {
if ( false === $related_posts_section_loaded ) {
if ( is_customize_preview() ) {
echo '<div class="customizer-item-block-preview customizer-navigate-on-focus ast-single-related-posts-container ' . esc_attr( $module_container_width ) . '" data-section="ast-sub-section-related-posts" data-type="section">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
Astra_Builder_UI_Controller::render_customizer_edit_button( 'row-editor-shortcut' );
} else {
echo '<div class="ast-single-related-posts-container ' . esc_attr( $module_container_width ) . '">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
do_action( 'astra_related_posts_title_before' );
if ( '' !== $related_posts_title ) {
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'astra_related_posts_title',
sprintf(
'<div class="ast-related-posts-title-section"> <%1$s class="ast-related-posts-title"> %2$s </%1$s> </div>',
apply_filters( 'astra_related_posts_box_heading_tag', 'h2' ),
$related_posts_title
)
);
}
do_action( 'astra_related_posts_title_after' );
echo '<div class="ast-related-posts-wrapper">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$related_posts_section_loaded = true;
}
?>
<article <?php post_class( 'ast-related-post' ); ?>>
<div class="ast-related-posts-inner-section">
<div class="ast-related-post-content">
<?php
// Render post based on order of Featured Image & Title-Meta.
if ( is_array( $related_post_structure ) ) {
foreach ( $related_post_structure as $post_thumb_title_order ) {
if ( 'featured-image' === $post_thumb_title_order ) {
do_action( 'astra_related_post_before_featured_image', $post_id );
$this->astra_get_related_post_featured_image( $post_id );
do_action( 'astra_related_post_after_featured_image', $post_id );
} else {
?>
<header class="entry-header related-entry-header">
<?php
$this->astra_get_related_post_title( $post_id );
echo apply_filters( 'astra_related_posts_meta_html', '<div class="entry-meta ast-related-cat-style--' . $related_category_style . ' ast-related-tag-style--' . $related_tag_style . '">' . $output_str . '</div>' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
</header>
<?php
}
}
}
?>
<div class="entry-content clear">
<?php
$this->astra_get_related_post_excerpt( $post_id );
$this->astra_get_related_post_read_more( $post_id );
?>
</div>
</div>
</div>
</article>
<?php
$post_counter++;
}
wp_reset_postdata();
}
if ( true === $related_posts_section_loaded ) {
echo '</div> </div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
do_action( 'astra_related_posts_loop_after' );
}
}
/**
* Render Post CTA button HTML marup.
*
* @param int $current_post_id current post ID.
*
* @since 3.5.0
*/
public function astra_get_related_post_read_more( $current_post_id ) {
if ( ! astra_get_option( 'enable-related-posts-excerpt' ) ) {
return;
}
$related_posts_content_type = apply_filters( 'astra_related_posts_content_type', 'excerpt' );
if ( 'full-content' === $related_posts_content_type ) {
return;
}
$target = apply_filters( 'astra_related_post_cta_target', '_self' );
$cta_text = apply_filters( 'astra_related_post_read_more_text', astra_get_i18n_option( 'blog-read-more-text', _x( '%astra%', 'Blogs: Read More Text', 'astra' ) ) );
$blog_read_more_as_button = astra_get_option( 'blog-read-more-as-button' );
$show_read_more_as_button = apply_filters( 'astra_related_post_read_more_as_button', $blog_read_more_as_button );
$class = '';
if ( $show_read_more_as_button ) {
$class = 'ast-button';
}
$custom_class = apply_filters( 'astra_related_post_cta_custom_classes', $class );
do_action( 'astra_related_post_before_cta', $current_post_id );
?>
<p class="ast-related-post-cta read-more">
<a class="ast-related-post-link <?php echo esc_attr( $custom_class ); ?>" href="<?php echo esc_url( apply_filters( 'astra_related_post_link', get_the_permalink(), $current_post_id ) ); ?>" aria-label="<?php echo esc_attr__( 'Related post link', 'astra' ); ?>" target="<?php echo esc_attr( $target ); ?>" rel="bookmark noopener noreferrer"><?php echo esc_html( $cta_text ); ?></a>
</p>
<?php
do_action( 'astra_related_post_after_cta', $current_post_id );
}
/**
* Related Posts Excerpt markup.
*
* @param int $current_post_id current post ID.
*
* @since 3.5.0
*/
public function astra_get_related_post_excerpt( $current_post_id ) {
if ( ! astra_get_option( 'enable-related-posts-excerpt' ) ) {
return;
}
$related_posts_content_type = apply_filters( 'astra_related_posts_content_type', 'excerpt' );
if ( 'full-content' === $related_posts_content_type ) {
return the_content();
}
$excerpt_length = absint( astra_get_option( 'related-posts-excerpt-count' ) );
$excerpt = wp_trim_words( get_the_excerpt(), $excerpt_length );
if ( ! $excerpt ) {
$excerpt = null;
}
$excerpt = apply_filters( 'astra_related_post_excerpt', $excerpt, $current_post_id );
do_action( 'astra_related_post_before_excerpt', $current_post_id );
?>
<p class="ast-related-post-excerpt entry-content clear">
<?php echo wp_kses_post( $excerpt ); ?>
</p>
<?php
do_action( 'astra_related_post_after_excerpt', $current_post_id );
}
/**
* Render Post Title HTML.
*
* @param int $current_post_id current post ID.
*
* @since 3.5.0
*/
public function astra_get_related_post_title( $current_post_id ) {
$related_post_structure = astra_get_option_meta( 'related-posts-structure' );
if ( ! in_array( 'title-meta', $related_post_structure ) ) {
return;
}
$target = apply_filters( 'astra_related_post_title_opening_target', '_self' );
$title_tag = apply_filters( 'astra_related_post_title_tag', 'h3' );
do_action( 'astra_related_post_before_title', $current_post_id );
?>
<<?php echo esc_html( $title_tag ); ?> class="ast-related-post-title entry-title">
<a href="<?php echo esc_url( apply_filters( 'astra_related_post_link', get_the_permalink(), $current_post_id ) ); ?>" target="<?php echo esc_attr( $target ); ?>" rel="bookmark noopener noreferrer"><?php the_title(); ?></a>
</<?php echo esc_html( $title_tag ); ?>>
<?php
do_action( 'astra_related_post_after_title', $current_post_id );
}
/**
* Render Featured Image HTML.
*
* @param int $current_post_id current post ID.
* @param string $before Markup before thumbnail image.
* @param string $after Markup after thumbnail image.
* @param boolean $echo Output print or return.
* @return string|null
*
* @since 3.5.0
*/
public function astra_get_related_post_featured_image( $current_post_id, $before = '', $after = '', $echo = true ) {
$related_post_structure = astra_get_option_meta( 'related-posts-structure' );
if ( ! in_array( 'featured-image', $related_post_structure ) ) {
return;
}
$featured_image_size = astra_get_option( 'related-posts-image-size', 'large' );
$thumbnail_id = get_post_thumbnail_id( $current_post_id );
$alt_text = $thumbnail_id ? get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true ) : '';
$post_thumb = apply_filters(
'astra_related_post_featured_image_markup',
get_the_post_thumbnail(
$current_post_id,
apply_filters( 'astra_related_posts_thumbnail_default_size', $featured_image_size ),
array(
'alt' => $alt_text ? $alt_text : get_the_title( $current_post_id ),
'itemprop' => apply_filters( 'astra_related_posts_thumbnail_itemprop', '' ),
)
)
);
$appended_class = has_post_thumbnail( $current_post_id ) ? 'post-has-thumb' : 'ast-no-thumb';
$featured_img_markup = '<div class="ast-related-post-featured-section ' . $appended_class . '">';
if ( '' !== $post_thumb ) {
$featured_img_markup .= '<div class="post-thumb-img-content post-thumb">';
$featured_img_markup .= astra_markup_open(
'ast-related-post-image',
array(
'open' => '<a %s>',
'echo' => false,
'attrs' => array(
'class' => '',
'aria-label' => sprintf( __( 'Read more about %s', 'astra' ), esc_attr( get_the_title( $current_post_id ) ) ),
'href' => esc_url( get_permalink() ),
),
)
);
$featured_img_markup .= $post_thumb;
$featured_img_markup .= '</a> </div>';
}
$featured_img_markup = apply_filters( 'astra_related_post_featured_image_after', $featured_img_markup );
$featured_img_markup .= '</div>';
$featured_img_markup = apply_filters( 'astra_related_post_thumbnail', $featured_img_markup, $before, $after );
if ( false === $echo ) {
return $before . $featured_img_markup . $after;
}
echo $before . $featured_img_markup . $after; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Get related posts based on configurations.
*
* @param int $post_id Current Post ID.
*
* @since 3.5.0
*
* @return WP_Query|bool
*/
public function astra_get_related_posts_by_query( $post_id ) {
$term_ids = array();
$current_post_type = get_post_type( $post_id );
$related_posts_total_count = absint( astra_get_option( 'related-posts-total-count', 2 ) );
// Taking one post extra in loop because if current post excluded from while loop then this extra one post will cover total post count. Apperently avoided 'post__not_in' from WP_Query.
$updated_total_posts_count = $related_posts_total_count + 1;
$related_posts_order_by = astra_get_option( 'related-posts-order-by', 'date' );
$related_posts_order = astra_get_option( 'related-posts-order', 'desc' );
$related_posts_based_on = astra_get_option( 'related-posts-based-on', 'categories' );
$query_args = array(
'update_post_meta_cache' => false,
'posts_per_page' => $updated_total_posts_count,
'no_found_rows' => true,
'post_status' => 'publish',
'post_type' => $current_post_type,
'orderby' => $related_posts_order_by,
'fields' => 'ids',
'order' => $related_posts_order,
);
if ( 'tags' === $related_posts_based_on ) {
$terms = get_the_tags( $post_id );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
$term_ids = wp_list_pluck( $terms, 'term_id' );
}
$query_args['tag__in'] = $term_ids;
} else {
$terms = get_the_category( $post_id );
/** @psalm-suppress RedundantConditionGivenDocblockType */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
/** @psalm-suppress RedundantConditionGivenDocblockType */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$term_ids = wp_list_pluck( $terms, 'term_id' );
}
$query_args['category__in'] = $term_ids;
}
$query_args = apply_filters( 'astra_related_posts_query_args', $query_args );
return new WP_Query( $query_args );
}
}
/**
* Kicking this off by creating NEW instance.
*/
new Astra_Related_Posts_Markup();

View File

@@ -0,0 +1,46 @@
<?php
/**
* Related Posts for Astra theme.
*
* @package Astra
* @link https://www.brainstormforce.com
* @since Astra 3.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'ASTRA_RELATED_POSTS_DIR', ASTRA_THEME_DIR . 'inc/modules/related-posts/' );
/**
* Related Posts Initial Setup
*
* @since 3.5.0
*/
class Astra_Related_Posts {
/**
* Constructor function that initializes required actions and hooks
*
* @since 3.5.0
*/
public function __construct() {
// @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
require_once ASTRA_RELATED_POSTS_DIR . 'class-astra-related-posts-loader.php';
require_once ASTRA_RELATED_POSTS_DIR . 'class-astra-related-posts-markup.php';
// @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
// Include front end files.
if ( ! is_admin() ) {
require_once ASTRA_RELATED_POSTS_DIR . 'css/static-css.php'; // phpcs:ignore: WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
require_once ASTRA_RELATED_POSTS_DIR . 'css/dynamic-css.php'; // phpcs:ignore: WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
}
}
}
/**
* Kicking this off by creating NEW instance.
*/
new Astra_Related_Posts();

View File

@@ -0,0 +1,269 @@
<?php
/**
* Related Posts - Dynamic CSS
*
* @package astra
* @since 3.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_filter( 'astra_dynamic_theme_css', 'astra_related_posts_css', 11 );
/**
* Related Posts - Dynamic CSS
*
* @param string $dynamic_css Astra Dynamic CSS.
* @return String Generated dynamic CSS for Related Posts.
*
* @since 3.4.0
*/
function astra_related_posts_css( $dynamic_css ) {
if ( astra_target_rules_for_related_posts() ) {
$link_color = astra_get_option( 'link-color' );
$related_posts_title_alignment = astra_get_option( 'releted-posts-title-alignment' );
// Added RTL language support for title alignment.
if ( is_rtl() && 'center' !== $related_posts_title_alignment ) {
$related_posts_title_alignment = ( 'left' === $related_posts_title_alignment ) ? 'right' : 'left';
}
// Related Posts Grid layout params.
$related_posts_grid = astra_get_option( 'related-posts-grid-responsive' );
$desktop_grid = ( isset( $related_posts_grid['desktop'] ) ) ? $related_posts_grid['desktop'] : '2-equal';
$tablet_grid = ( isset( $related_posts_grid['tablet'] ) ) ? $related_posts_grid['tablet'] : '2-equal';
$mobile_grid = ( isset( $related_posts_grid['mobile'] ) ) ? $related_posts_grid['mobile'] : 'full';
// Related Posts -> Post Title typography dynamic stylings.
$related_post_title_font_size = astra_get_option( 'related-posts-title-font-size' );
// Related Posts -> Post Meta typography dynamic stylings.
$related_post_meta_font_size = astra_get_option( 'related-posts-meta-font-size' );
// Related Posts -> Content typography dynamic stylings.
$related_post_content_font_size = astra_get_option( 'related-posts-content-font-size' );
// Related Posts -> Section Title typography dynamic stylings.
$related_posts_section_title_font_size = astra_get_option( 'related-posts-section-title-font-size' );
// Setting up container BG color by default to Related Posts's section BG color.
$content_bg_obj = astra_get_option( 'content-bg-obj-responsive' );
$container_bg_color = '#ffffff';
if ( isset( $content_bg_obj['desktop']['background-color'] ) && '' !== $content_bg_obj['desktop']['background-color'] ) {
$container_bg_color = $content_bg_obj['desktop']['background-color'];
}
// Related Posts -> Color dynamic stylings.
$related_posts_title_color = astra_get_option( 'related-posts-title-color' );
/** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$related_posts_bg_color = astra_get_option( 'related-posts-background-color', $container_bg_color );
$related_post_text_color = astra_get_option( 'related-posts-text-color' );
$related_posts_meta_color = astra_get_option( 'related-posts-meta-color' );
$related_posts_link_color = astra_get_option( 'related-posts-link-color' );
$related_posts_link_hover_color = astra_get_option( 'related-posts-link-hover-color' );
$related_posts_meta_link_hover_color = astra_get_option( 'related-posts-meta-link-hover-color' );
$author_avatar_size = astra_get_option( 'related-posts-author-avatar-size' );
// Aspect Ratio processing.
$aspect_ratio_type = astra_get_option( 'related-posts-image-ratio-type', '' );
$predefined_scale = astra_get_option( 'related-posts-image-ratio-pre-scale' );
$custom_scale_width = astra_get_option( 'related-posts-image-custom-scale-width', 16 );
$custom_scale_height = astra_get_option( 'related-posts-image-custom-scale-height', 9 );
$aspect_ratio = astra_get_dynamic_image_aspect_ratio( $aspect_ratio_type, $predefined_scale, $custom_scale_width, $custom_scale_height );
$with_aspect_img_width = 'predefined' === $aspect_ratio_type || 'custom' === $aspect_ratio_type ? '100%' : '';
$object_fit = 'custom' === $aspect_ratio_type ? 'cover' : '';
$css_desktop_output = array(
'.ast-single-related-posts-container .ast-related-posts-wrapper' => array(
'grid-template-columns' => Astra_Builder_Helper::$grid_size_mapping[ $desktop_grid ],
),
'.ast-related-posts-inner-section .ast-date-meta .posted-on, .ast-related-posts-inner-section .ast-date-meta .posted-on *' => array(
'background' => esc_attr( $link_color ),
'color' => astra_get_foreground_color( $link_color ),
),
'.ast-related-posts-inner-section .ast-date-meta .posted-on .date-month, .ast-related-posts-inner-section .ast-date-meta .posted-on .date-year' => array(
'color' => astra_get_foreground_color( $link_color ),
),
'.ast-single-related-posts-container' => array(
'background-color' => esc_attr( $related_posts_bg_color ),
),
/**
* Related Posts - Section Title
*/
'.ast-related-posts-title' => astra_get_font_array_css( astra_get_option( 'related-posts-section-title-font-family' ), astra_get_option( 'related-posts-section-title-font-weight' ), $related_posts_section_title_font_size, 'related-posts-section-title-font-extras', $related_posts_title_color ),
'.ast-related-posts-title-section .ast-related-posts-title' => array(
'text-align' => esc_attr( $related_posts_title_alignment ),
),
/**
* Related Posts - Post Title
*/
'.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' => astra_get_font_array_css( astra_get_option( 'related-posts-title-font-family' ), astra_get_option( 'related-posts-title-font-weight' ), $related_post_title_font_size, 'related-posts-title-font-extras', $related_post_text_color ),
/**
* Related Posts - Meta
*/
'.ast-related-post-content .entry-meta, .ast-related-post-content .entry-meta *' => astra_get_font_array_css( astra_get_option( 'related-posts-meta-font-family' ), astra_get_option( 'related-posts-meta-font-weight' ), $related_post_meta_font_size, 'related-posts-meta-font-extras', $related_posts_meta_color ),
'.ast-related-post-content .entry-meta a:hover, .ast-related-post-content .entry-meta span a span:hover' => array(
'color' => esc_attr( $related_posts_meta_link_hover_color ),
),
/**
* Related Posts - CTA
*/
'.ast-related-post-cta a' => array(
'color' => esc_attr( $related_posts_link_color ),
),
'.ast-related-post-cta a:hover' => array(
'color' => esc_attr( $related_posts_link_hover_color ),
),
/**
* Related Posts - Content
*/
'.ast-related-post-excerpt' => astra_get_font_array_css( astra_get_option( 'related-posts-content-font-family' ), astra_get_option( 'related-posts-content-font-weight' ), $related_post_content_font_size, 'related-posts-content-font-extras', $related_post_text_color ),
'.ast-related-post-content .post-thumb-img-content img' => array(
'aspect-ratio' => $aspect_ratio,
'width' => $with_aspect_img_width,
'object-fit' => $object_fit, // setting it to 'cover' for custom ratio option same as blogs archive page.
),
'.ast-related-post-content .ast-author-avatar' => array(
'--ast-author-avatar-size' => astra_get_css_value( $author_avatar_size, 'px' ),
),
);
if ( astra_has_global_color_format_support() ) {
/** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$related_posts_bg_color = astra_get_option( 'related-posts-background-color', $content_bg_obj );
if ( is_array( $related_posts_bg_color ) ) {
$css_desktop_output['.ast-single-related-posts-container'] = astra_get_responsive_background_obj( $related_posts_bg_color, 'desktop' );
} else {
$css_desktop_output['.ast-single-related-posts-container'] = array(
'background-color' => esc_attr( $related_posts_bg_color ),
);
}
}
$btn_text_color = astra_get_option( 'button-color', '#fff' );
$btn_border_color = astra_get_option( 'theme-button-border-group-border-color' );
$btn_border_h_color = astra_get_option( 'theme-button-border-group-border-h-color' );
$theme_color = astra_get_option( 'theme-color' );
$link_hover_color = astra_get_option( 'link-h-color' );
$btn_bg_color = astra_get_option( 'button-bg-color', $theme_color );
$btn_text_hover_color = astra_get_option( 'button-h-color', '#fff' );
$btn_bg_hover_color = astra_get_option( 'button-bg-h-color', $link_hover_color );
$btn_preset_style = astra_get_option( 'button-preset-style' );
$global_custom_button_border_size = astra_get_option( 'theme-button-border-group-border-size' );
if ( 'button_04' === $btn_preset_style || 'button_05' === $btn_preset_style || 'button_06' === $btn_preset_style ) {
if ( empty( $btn_border_color ) ) {
$btn_border_color = $btn_bg_color;
}
if ( '' === astra_get_option( 'button-bg-color' ) && '' === astra_get_option( 'button-color' ) ) {
$btn_text_color = $theme_color;
} elseif ( '' === astra_get_option( 'button-color' ) ) {
$btn_text_color = $btn_bg_color;
}
$btn_bg_color = 'transparent';
}
$css_desktop_output['.ast-related-cat-style--badge .cat-links > a, .ast-related-tag-style--badge .tags-links > a'] = array(
'border-style' => 'solid',
'border-top-width' => ( isset( $global_custom_button_border_size['top'] ) && '' !== $global_custom_button_border_size['top'] ) ? astra_get_css_value( $global_custom_button_border_size['top'], 'px' ) : '0',
'border-right-width' => ( isset( $global_custom_button_border_size['right'] ) && '' !== $global_custom_button_border_size['right'] ) ? astra_get_css_value( $global_custom_button_border_size['right'], 'px' ) : '0',
'border-left-width' => ( isset( $global_custom_button_border_size['left'] ) && '' !== $global_custom_button_border_size['left'] ) ? astra_get_css_value( $global_custom_button_border_size['left'], 'px' ) : '0',
'border-bottom-width' => ( isset( $global_custom_button_border_size['bottom'] ) && '' !== $global_custom_button_border_size['bottom'] ) ? astra_get_css_value( $global_custom_button_border_size['bottom'], 'px' ) : '0',
'padding' => '4px 8px',
'border-radius' => '3px',
'font-size' => 'inherit',
'color' => esc_attr( $btn_text_color ),
'border-color' => empty( $btn_border_color ) ? esc_attr( $btn_bg_color ) : esc_attr( $btn_border_color ),
'background-color' => esc_attr( $btn_bg_color ),
);
$css_desktop_output['.ast-related-cat-style--badge .cat-links > a:hover, .ast-related-tag-style--badge .tags-links > a:hover'] = array(
'color' => esc_attr( $btn_text_hover_color ),
'background-color' => esc_attr( $btn_bg_hover_color ),
'border-color' => empty( $btn_border_h_color ) ? esc_attr( $btn_bg_hover_color ) : esc_attr( $btn_border_h_color ),
);
$css_desktop_output['.ast-related-cat-style--underline .cat-links > a, .ast-related-tag-style--underline .tags-links > a'] = array(
'text-decoration' => 'underline',
);
$dynamic_css .= astra_parse_css( $css_desktop_output );
$css_max_tablet_output = array(
'.ast-single-related-posts-container .ast-related-posts-wrapper .ast-related-post' => array(
'width' => '100%',
),
'.ast-single-related-posts-container .ast-related-posts-wrapper' => array(
'grid-template-columns' => Astra_Builder_Helper::$grid_size_mapping[ $tablet_grid ],
),
'.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' => array(
'font-size' => astra_responsive_font( $related_post_title_font_size, 'tablet' ),
),
'.ast-related-post-content .entry-meta *' => array(
'font-size' => astra_responsive_font( $related_post_meta_font_size, 'tablet' ),
),
'.ast-related-post-excerpt' => array(
'font-size' => astra_responsive_font( $related_post_content_font_size, 'tablet' ),
),
'.ast-related-posts-title' => array(
'font-size' => astra_responsive_font( $related_posts_section_title_font_size, 'tablet' ),
),
);
if ( astra_has_global_color_format_support() ) {
if ( is_array( $related_posts_bg_color ) ) {
$css_max_tablet_output['.ast-single-related-posts-container'] = astra_get_responsive_background_obj( $related_posts_bg_color, 'desktop' );
} else {
$css_max_tablet_output['.ast-single-related-posts-container'] = array(
'background-color' => esc_attr( $related_posts_bg_color ),
);
}
}
$dynamic_css .= astra_parse_css( $css_max_tablet_output, '', astra_get_tablet_breakpoint() );
$css_max_mobile_output = array(
'.ast-single-related-posts-container .ast-related-posts-wrapper' => array(
'grid-template-columns' => Astra_Builder_Helper::$grid_size_mapping[ $mobile_grid ],
),
'.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' => array(
'font-size' => astra_responsive_font( $related_post_title_font_size, 'mobile' ),
),
'.ast-related-post-content .entry-meta *' => array(
'font-size' => astra_responsive_font( $related_post_meta_font_size, 'mobile' ),
),
'.ast-related-post-excerpt' => array(
'font-size' => astra_responsive_font( $related_post_content_font_size, 'mobile' ),
),
'.ast-related-posts-title' => array(
'font-size' => astra_responsive_font( $related_posts_section_title_font_size, 'mobile' ),
),
);
if ( astra_has_global_color_format_support() ) {
if ( is_array( $related_posts_bg_color ) ) {
$css_max_mobile_output['.ast-single-related-posts-container'] = astra_get_responsive_background_obj( $related_posts_bg_color, 'desktop' );
} else {
$css_max_mobile_output['.ast-single-related-posts-container'] = array(
'background-color' => esc_attr( $related_posts_bg_color ),
);
}
}
$dynamic_css .= astra_parse_css( $css_max_mobile_output, '', astra_get_mobile_breakpoint() );
$dynamic_css .= Astra_Extended_Base_Dynamic_CSS::prepare_inner_section_advanced_css( 'ast-sub-section-related-posts', '.site .ast-single-related-posts-container' );
return $dynamic_css;
}
return $dynamic_css;
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* Related Posts - Static CSS
*
* @package astra
*
* @since 3.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_filter( 'astra_dynamic_theme_css', 'astra_related_posts_static_css', 11 );
/**
* Related Posts - Static CSS
*
* @param string $dynamic_css Astra Dynamic CSS.
* @return String Generated dynamic CSS for Related Posts.
*
* @since 3.5.0
*/
function astra_related_posts_static_css( $dynamic_css ) {
if ( astra_target_rules_for_related_posts() ) {
$dynamic_css .= '
.ast-related-post-title, .entry-meta * {
word-break: break-word;
}
.ast-related-post-cta.read-more .ast-related-post-link {
text-decoration: none;
}
.ast-page-builder-template .ast-related-post .entry-header, .ast-related-post-content .entry-header, .ast-related-post-content .entry-meta {
margin: 1em auto 1em auto;
padding: 0;
}
.ast-related-posts-wrapper {
display: grid;
grid-column-gap: 25px;
grid-row-gap: 25px;
}
.ast-related-posts-wrapper .ast-related-post, .ast-related-post-featured-section {
padding: 0;
margin: 0;
width: 100%;
position: relative;
}
.ast-related-posts-inner-section {
height: 100%;
}
.post-has-thumb + .entry-header, .post-has-thumb + .entry-content {
margin-top: 1em;
}
.ast-related-post-content .entry-meta {
margin-top: 0.5em;
}
.ast-related-posts-inner-section .post-thumb-img-content {
margin: 0;
position: relative;
}
';
if ( true === astra_check_is_structural_setup() ) {
/** @psalm-suppress InvalidOperand */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$astra_mobile_breakpoint = astra_get_mobile_breakpoint();
/** @psalm-suppress InvalidOperand */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$section_title_bottom_space = Astra_Dynamic_CSS::astra_4_6_0_compatibility() ? '20px' : '2em';
$dynamic_css .= '
.ast-single-related-posts-container {
border-top: 1px solid var(--ast-single-post-border, var(--ast-border-color));
}
.ast-separate-container .ast-single-related-posts-container {
border-top: 0;
}
.ast-single-related-posts-container {
padding-top: 2em;
}
.ast-related-posts-title-section {
padding-bottom: ' . $section_title_bottom_space . ';
}
.ast-page-builder-template .ast-single-related-posts-container {
margin-top: 0;
padding-left: 20px;
padding-right: 20px;
}
@media (max-width: ' . strval( $astra_mobile_breakpoint ) . 'px) {
.ast-related-posts-title-section {
padding-bottom: 1.5em;
}
}
';
} else {
$dynamic_css .= '
.ast-separate-container .ast-related-posts-title {
margin: 0 0 20px 0;
}
.ast-related-posts-title-section {
border-top: 1px solid #eeeeee;
}
.ast-related-posts-title {
margin: 20px 0;
}
.ast-page-builder-template .ast-related-posts-title-section, .ast-page-builder-template .ast-single-related-posts-container {
padding: 0 20px;
}
.ast-separate-container .ast-single-related-posts-container {
padding: 5.34em 6.67em;
}
.ast-single-related-posts-container {
margin: 2em 0;
}
.ast-separate-container .ast-related-posts-title-section, .ast-page-builder-template .ast-single-related-posts-container {
border-top: 0;
margin-top: 0;
}
@media (max-width: 1200px) {
.ast-separate-container .ast-single-related-posts-container {
padding: 3.34em 2.4em;
}
}
';
}
return $dynamic_css;
}
return $dynamic_css;
}