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/linde/wp-content/themes/linde/single-linde_course.php
<?php

    $context     = Timber::context();
    $timber_post = Timber::get_post(false, "PostCourse");
    $comingSoon = $timber_post->meta( 'coming_soon' );
    $allowViewing = $timber_post->meta( 'allow_viewing_of_full_course_page' );
    $context['post'] = $timber_post;
    $context['current_url'] = Timber\URLHelper::get_current_url();
    
    if( $comingSoon && ! $allowViewing) {

        Timber::render( '404.twig', $context );

    } else {

        $terms = $timber_post->terms( 'linde_module' );

        $session_number = $timber_post->meta('session_number');

        if(count($terms) > 0){

            $context['term'] = new Timber\Term($terms[0]->ID);

            $term_id = $terms[0]->ID;



            $args = array(
                'post_type' => 'linde_course',
                'posts_per_page' => 50,
                'orderby' => 'date',
                'order'   => 'DESC',
                'meta_query'	=> array(
                    'relation'		=> 'OR',

                    array(
                        'key'	  	=> 'session_number',
                        'value'	  	=> $session_number - 1,
                        'compare' 	=> '=',
                    ),
                ),
                'tax_query' => array(
                    array(
                        'taxonomy' => 'linde_module',
                        'field'    => 'term_id',
                        'terms'    => $term_id,
                    ),
                ));
            $previous_course = Timber::get_posts($args, "PostCourse");

            $args = array(
                'post_type' => 'linde_course',
                'posts_per_page' => 50,
                'orderby' => 'date',
                'order'   => 'DESC',
                'meta_query'	=> array(
                    'relation'		=> 'OR',
                    array(
                        'key'	 	=> 'session_number',
                        'value'	  	=> $session_number + 1,
                        'compare' 	=> '=',
                    ),

                ),
                'tax_query' => array(
                    array(
                        'taxonomy' => 'linde_module',
                        'field'    => 'term_id',
                        'terms'    => $term_id,
                    ),
                ));
            $next_course = Timber::get_posts($args, "PostCourse");



            if($previous_course && count($previous_course) > 0) {
                $context['previous_course'] = $previous_course[0];
            }
            if($next_course && count($next_course) > 0) {
                $context['next_course'] = $next_course[0];
            }

        }

        if ( post_password_required( $timber_post->ID ) ) {
            Timber::render( 'single-password.twig', $context );
        } else {
            Timber::render( array( 'single-' . $timber_post->ID . '.twig', 'single-' . $timber_post->post_type . '.twig', 'single-' . $timber_post->slug . '.twig', 'single.twig' ), $context );
        }   
        
    }