| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/www/wp-content/themes/trackstore/framework/modules/header/lib/ |
Upload File : |
<?php
namespace TrackStoreElated\Modules\Header\Lib;
/**
* Class TrackStoreElatedHeaderConnector
*
* Connects header module with other modules
*/
class TrackStoreElatedHeaderConnector {
/**
* @param HeaderType $object
*/
public function __construct( HeaderType $object ) {
$this->object = $object;
}
/**
* Connects given object with other modules based on pased config
*
* @param array $config
*/
public function connect( $config = array() ) {
do_action( 'trackstore_elated_pre_header_connect' );
$defaultConfig = array(
'affect_content' => true,
'affect_title' => true,
'affect_slider' => true
);
if ( is_array( $config ) && count( $config ) ) {
$config = array_merge( $defaultConfig, $config );
}
if ( ! empty( $config['affect_content'] ) ) {
add_filter( 'trackstore_elated_content_elem_style_attr', array( $this, 'contentMarginFilter' ) );
}
if ( ! empty( $config['affect_title'] ) ) {
add_filter( 'trackstore_elated_title_content_padding', array( $this, 'titlePaddingFilter' ) );
}
do_action( 'trackstore_elated_after_header_connect' );
}
/**
* Adds margin-top property to content element based on height of transparent parts of header
*
* @param $styles
*
* @return array
*/
public function contentMarginFilter( $styles ) {
$marginTopValue = $this->object->getHeightOfTransparency();
if ( ! empty( $marginTopValue ) ) {
$styles[] = 'margin-top: -' . $marginTopValue . 'px';
}
return $styles;
}
/**
* Returns padding value calculated from transparent header parts.
*
* Hooks to trackstore_elated_title_content_padding filter
*
* @return int
*/
public function titlePaddingFilter() {
$heightOfTransparency = $this->object->getHeightOfTransparency();
return ! empty( $heightOfTransparency ) ? $heightOfTransparency : 0;
}
}