/home/bdqbpbxa/demo-subdomains/paytech.goodface.com.ua/wp-content/themes/paytech/functions.php
<?php
// Require settings and helpers
$theme_uri_arr = explode('/', get_template_directory_uri());
$theme_folder_name = end($theme_uri_arr);
$theme_root_path = get_theme_root() . '/' . $theme_folder_name;
require $theme_root_path . '/functions/settings/acf-settings.php';
require $theme_root_path . '/functions/settings/cf7-settings.php';
require $theme_root_path . '/functions/settings/wp-output-html-settings.php';
require $theme_root_path . '/functions/settings/wysiwyg-editor-settings.php';
if (function_exists('pll_current_language')) {
require $theme_root_path . '/functions/settings/polylang-og-settings.php';
}
require $theme_root_path . '/functions/helpers/helper-functions.php';
require $theme_root_path . '/functions/helpers/helper-shortcodes.php';
// Add custom styles to admin panel
function add_custom_admin_styles() {
wp_enqueue_style('admin-panel-custom-styles', get_template_directory_uri() . '/assets-admin/css/admin-panel.css');
}
add_action('admin_enqueue_scripts', 'add_custom_admin_styles');
// Create option pages
if (function_exists('acf_add_options_page')) {
acf_add_options_page(array(
'page_title' => 'Global settings',
'menu_title' => 'Global settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'Header',
'menu_title' => 'Header',
'menu_slug' => 'global-settings-header',
'parent_slug' => 'theme-general-settings'
));
acf_add_options_sub_page(array(
'page_title' => 'Footer',
'menu_title' => 'Footer',
'menu_slug' => 'global-settings-footer',
'parent_slug' => 'theme-general-settings'
));
}
function _bot_detected() {
$is_bot = false;
$user_agents = array( 'Moto G' );
$user_agent = $_SERVER['HTTP_USER_AGENT'];
foreach ( $user_agents as $agent ){
if ( strpos( $user_agent, $agent) ){
$is_bot = true;
}
}
return $is_bot;
}
function isCurrentPageVisited() {
$visitedPageCookie = isset($_COOKIE['visitedPage']) ? $_COOKIE['visitedPage'] : '';
$currentPage = $_SERVER['REQUEST_URI'];
return $visitedPageCookie !== '' && strpos($visitedPageCookie, $currentPage) !== false;
}
// Include styles and scripts
function include_styles_and_scripts() {
$curr_post = get_post();
wp_enqueue_style('swiper-bundle', get_template_directory_uri() . '/assets/css/lib/swiper-bundle.min.css', array(), '1.5.1');
wp_enqueue_style('ui-kit', get_template_directory_uri() . '/assets/css/ui-kit.css', array(), '1.5.1');
wp_enqueue_style('dots-animations.css', get_template_directory_uri() . '/assets/css/ui-kit/dots-animations.css', array(), '1.5.1');
wp_enqueue_style('ui-blocks', get_template_directory_uri() . '/assets/css/ui-blocks.css', array(), '1.5.1');
wp_enqueue_style('hovers', get_template_directory_uri() . '/assets/css/hovers.css', array(), '1.5.1');
wp_enqueue_style('styles', get_template_directory_uri() . '/assets/css/styles.css', array(), '1.5.1');
wp_enqueue_style('custom-animations', get_template_directory_uri() . '/assets/css/custom-animations.css', array(), '1.5.1');
wp_enqueue_style('scroll-animations', get_template_directory_uri() . '/assets/css/lib/scroll-animations.css', array(), '1.5.1');
wp_enqueue_style('overlay-scrollbars', get_template_directory_uri() . '/assets/css/lib/overlay-scrollbars.min.css', array(), '1.5.1');
wp_enqueue_style('adaptive', get_template_directory_uri() . '/assets/css/adaptive.css', array(), '1.5.1');
wp_enqueue_style('reviews', get_template_directory_uri() . '/assets/css/separated-styles/reviews.css', array(), '1.5.1');
wp_enqueue_style('blog.css', get_template_directory_uri() . '/assets/css/separated-styles/blog.css', array(), '1.5.1' );
if (!is_404()) {
// Home styles
if (is_front_page()) {
wp_enqueue_style('integrations-hub', get_template_directory_uri() . '/assets/css/separated-styles/integrations-hub.css', array(), '1.5.1');
wp_enqueue_style('services', get_template_directory_uri() . '/assets/css/separated-styles/services.css', array(), '1.5.1');
wp_enqueue_style('tabs', get_template_directory_uri() . '/assets/css/separated-styles/tabs.css', array(), '1.5.1');
wp_enqueue_style('title-section', get_template_directory_uri() . '/assets/css/separated-styles/title-section.css', array(), '1.5.1');
wp_enqueue_style('homepage', get_template_directory_uri() . '/assets/css/separated-styles/homepage.css', array(), '1.5.1');
wp_enqueue_style('faq', get_template_directory_uri() . '/assets/css/separated-styles/faq.css', array(), '1.5.1');
wp_enqueue_style('success-story', get_template_directory_uri() . '/assets/css/separated-styles/success-story.css', array(), '1.5.1');
}
// Banking styles
if ($curr_post->ID == 759) {
wp_enqueue_style('banking', get_template_directory_uri() . '/assets/css/separated-styles/banking.css', array(), '1.5.1');
wp_enqueue_style('tabs', get_template_directory_uri() . '/assets/css/separated-styles/tabs.css', array(), '1.5.1');
wp_enqueue_style('faq', get_template_directory_uri() . '/assets/css/separated-styles/faq.css', array(), '1.5.1');
wp_enqueue_style('success-story', get_template_directory_uri() . '/assets/css/separated-styles/success-story.css', array(), '1.5.1');
}
// Payment gateway
if ($curr_post->ID == 758) {
wp_enqueue_style('tabs', get_template_directory_uri() . '/assets/css/separated-styles/tabs.css', array(), '1.5.1');
wp_enqueue_style('faq', get_template_directory_uri() . '/assets/css/separated-styles/faq.css', array(), '1.5.1');
wp_enqueue_style('payment-gateway', get_template_directory_uri() . '/assets/css/separated-styles/payment-gateway.css', array(), '1.5.1');
wp_enqueue_style('success-story', get_template_directory_uri() . '/assets/css/separated-styles/success-story.css', array(), '1.5.1');
wp_enqueue_style('pricing', get_template_directory_uri() . '/assets/css/separated-styles/pricing.css', array(), '1.5.1');
}
// integrations hub
if ($curr_post->ID == 761) {
wp_enqueue_style('integrations-hub', get_template_directory_uri() . '/assets/css/separated-styles/integrations-hub.css', array(), '1.5.1');
}
// services
if ($curr_post->post_type == 'services') {
wp_enqueue_style('services', get_template_directory_uri() . '/assets/css/separated-styles/services.css', array(), '1.5.1');
wp_enqueue_style('title-section', get_template_directory_uri() . '/assets/css/separated-styles/title-section.css', array(), '1.5.1');
}
// pricing page
if ($curr_post->ID == 320) {
wp_enqueue_style('pricing', get_template_directory_uri() . '/assets/css/separated-styles/pricing.css', array(), '1.5.1');
}
// developers page
if ($curr_post->ID == 1833) {
wp_enqueue_style('developers', get_template_directory_uri() . '/assets/css/separated-styles/developers.css', array(), '1.5.1');
}
// About us page
if ($curr_post->ID == 331) {
wp_enqueue_style('about-us', get_template_directory_uri() . '/assets/css/separated-styles/about-us.css', array(), '1.5.1');
wp_enqueue_style('title-section', get_template_directory_uri() . '/assets/css/separated-styles/title-section.css', array(), '1.5.1');
}
// Careers page
if ($curr_post->ID == 360 || $curr_post->post_type == 'position') {
wp_enqueue_style('careers', get_template_directory_uri() . '/assets/css/separated-styles/careers.css', array(), '1.5.1');
}
// Success page
if ($curr_post->ID == 336) {
wp_enqueue_style('success-story', get_template_directory_uri() . '/assets/css/separated-styles/success-story.css', array(), '1.5.1');
wp_enqueue_style('tabs', get_template_directory_uri() . '/assets/css/separated-styles/tabs.css', array(), '1.5.1');
wp_enqueue_style('title-section', get_template_directory_uri() . '/assets/css/separated-styles/title-section.css', array(), '1.5.1');
wp_enqueue_style('pricing', get_template_directory_uri() . '/assets/css/separated-styles/pricing.css', array(), '1.5.1');
}
// Get started
if ($curr_post->ID == 322) {
wp_enqueue_style('get-started', get_template_directory_uri() . '/assets/css/separated-styles/get-started.css', array(), '1.5.1');
wp_enqueue_style('flag-icon', get_template_directory_uri() . '/assets/css/lib/flag-icon.min.css', array(), '1.5.1');
}
}
wp_deregister_script('jquery');
wp_enqueue_script('jquery-3.7.0.min.js', get_template_directory_uri() . '/assets/js/lib/jquery-3.7.0.min.js', array(), '1.5.1', array('in_footer' => true));
wp_enqueue_script('gsap.min.js', get_template_directory_uri() . '/assets/js/lib/gsap.min.js', array(), '1.5.1', array('in_footer' => true));
wp_enqueue_script('ScrollTrigger.min.js', get_template_directory_uri() . '/assets/js/lib/ScrollTrigger.min.js', array(), '1.5.1', array('in_footer' => true));
wp_enqueue_script('swiper-bundle.min.js', get_template_directory_uri() . '/assets/js/lib/swiper-bundle.min.js', array(), '1.5.1', array('in_footer' => true));
wp_enqueue_script('jquery.overlay-scrollbars', get_template_directory_uri() . '/assets/js/lib/jquery.overlay-scrollbars.min.js', array(), '1.5.1', array('in_footer' => true));
wp_enqueue_script('MotionPathPlugin.js', get_template_directory_uri() . '/assets/js/lib/MotionPathPlugin.js', array(), '1.5.1', array('in_footer' => true));
if (isCurrentPageVisited()) {
// load anime js if there is no preloader
wp_enqueue_script('anime.js', get_template_directory_uri() . '/assets/js/lib/anime.min.js', array(), '1.5.1', array('in_footer' => true));
}
wp_enqueue_script('custom-solutions.js', get_template_directory_uri() . '/assets/js/custom-solutions.js', array(), '1.5.1', array('in_footer' => true));
if (!is_404() && $curr_post->ID == 331) {
//about us
wp_enqueue_script('about-us.js', get_template_directory_uri() . '/assets/js/separated-scripts/about-us.js', array(), '1.5.1', array('in_footer' => true));
}
wp_enqueue_script('script', get_template_directory_uri() . '/assets/js/script.js', array(), '1.5.1', array('in_footer' => true));
wp_enqueue_script('animations.js', get_template_directory_uri() . '/assets/js/animations.js', array(), '1.5.1', array('in_footer' => true));
if (!is_404() && $curr_post->ID == 759) {
//banking
wp_enqueue_script('banking.js', get_template_directory_uri() . '/assets/js/separated-scripts/banking.js', array(), '1.5.1', array('in_footer' => true));
}
wp_enqueue_script('dots-animation.js', get_template_directory_uri() . '/assets/js/separated-scripts/dots-animation.js', array(), '1.5.1', array('in_footer' => true));
if (!is_404() && $curr_post->ID == 322) {
// get started
wp_enqueue_script('getStarted.js', get_template_directory_uri() . '/assets/js/separated-scripts/getStarted.js', array(), '1.5.1', array('in_footer' => true));
}
if (is_front_page()) {
wp_enqueue_script('homepage.js', get_template_directory_uri() . '/assets/js/separated-scripts/homepage.js', array(), '1.5.1', array('in_footer' => true));
}
if (!is_404() && $curr_post->post_type == 'services') {
wp_enqueue_script('services.js', get_template_directory_uri() . '/assets/js/separated-scripts/services.js', array(), '1.5.1', array('in_footer' => true));
wp_enqueue_script('products.js', get_template_directory_uri() . '/assets/js/separated-scripts/products.js', array(), '1.5.1', array('in_footer' => true));
}
if (!is_404() && $curr_post->post_type == 'products') {
wp_enqueue_script('products.js', get_template_directory_uri() . '/assets/js/separated-scripts/products.js', array(), '1.5.1', array('in_footer' => true));
}
// Backend scripts, used for ajax, requests, etc
wp_enqueue_script('backend-script', get_template_directory_uri() . '/assets-backend/script.js', array(), '1.5.1', array('in_footer' => true));
}
add_action('wp_enqueue_scripts', 'include_styles_and_scripts');
// ajax filter
add_action('wp_ajax_blog_filter', 'blog_filter_function');
add_action('wp_ajax_nopriv_blog_filter', 'blog_filter_function');
function blog_filter_function() {
get_template_part('templates/blog-list');
wp_die();
}
// integrations ajax filter
add_action('wp_ajax_integrations_filter', 'integrations_filter_function');
add_action('wp_ajax_nopriv_integrations_filter', 'integrations_filter_function');
function integrations_filter_function() {
get_template_part('templates/integrations/integrations-list');
wp_die();
}
function findObjectByReviewId($arrayOfObjects, $searchValue) {
foreach ($arrayOfObjects as $object) {
if ($object['review_id'] === $searchValue) {
return $object;
}
}
return null;
}
function make_images_bordered($html) {
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
libxml_clear_errors();
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
$spanImg = $dom->createElement('span');
$spanImg->setAttribute('class', 'img');
$spanImgWrapper = $dom->createElement('span');
$spanImgWrapper->setAttribute('class', 'img-wrapper');
$imageParent = $image->parentNode;
$imageParent->replaceChild($spanImg, $image);
$spanImg->appendChild($spanImgWrapper);
$spanImgWrapper->appendChild($image);
}
return $dom->saveHTML();
}
?>