/var/www/html/public/content/themes/pbc/sidebar.php
$tax = false;
$cat = false;
if ( is_tag() ) {
$context['popular']['title'] = 'Popular in '.ucfirst(single_tag_title( '', false ));
$tax = 'tag_id';
$post_type = ['post','podcast_episodes'];
} else if ( is_category() ) {
$context['popular']['title'] = 'Popular in '.single_cat_title( '', false );
$tax = 'cat';
} /*else if ( is_post_type_archive() ) {
$context['popular']['title'] = 'Popular in '.post_type_archive_title( '', false );
}*/
if($tax){
$the_object = get_queried_object();
$cat = isset($the_object->term_id) ? $the_object->term_id : false;
}
if(is_singular('post')){
$full_cat = get_the_category();
$tax = 'cat';
$cat = $full_cat[0]->term_id;
$context['popular']['title'] = 'Popular in '.$full_cat[0]->name;
}
//posts[0].category
$opts = [
'post_type' => $post_type,
'posts_per_page' => 4,
];
if($tax) $opts[$tax] = $cat;
$context['popular']['posts'] = Timber::get_posts($opts,'\PBC\Post');
$context['ad_code'] = "P2_SIDEBAR_".(isset($context['user']) && $context['user'] ? "LOGGED_IN_" : "");
Timber::render( array( 'sidebar.twig' ), $context );
wp_reset_query();
/var/www/html/public/content/themes/pbc/sidebar.php
$tax = false;
$cat = false;
if ( is_tag() ) {
$context['popular']['title'] = 'Popular in '.ucfirst(single_tag_title( '', false ));
$tax = 'tag_id';
$post_type = ['post','podcast_episodes'];
} else if ( is_category() ) {
$context['popular']['title'] = 'Popular in '.single_cat_title( '', false );
$tax = 'cat';
} /*else if ( is_post_type_archive() ) {
$context['popular']['title'] = 'Popular in '.post_type_archive_title( '', false );
}*/
if($tax){
$the_object = get_queried_object();
$cat = isset($the_object->term_id) ? $the_object->term_id : false;
}
if(is_singular('post')){
$full_cat = get_the_category();
$tax = 'cat';
$cat = $full_cat[0]->term_id;
$context['popular']['title'] = 'Popular in '.$full_cat[0]->name;
}
//posts[0].category
$opts = [
'post_type' => $post_type,
'posts_per_page' => 4,
];
if($tax) $opts[$tax] = $cat;
$context['popular']['posts'] = Timber::get_posts($opts,'\PBC\Post');
$context['ad_code'] = "P2_SIDEBAR_".(isset($context['user']) && $context['user'] ? "LOGGED_IN_" : "");
Timber::render( array( 'sidebar.twig' ), $context );
wp_reset_query();
/var/www/html/vendor/timber/timber/lib/Timber.php
return self::get_sidebar_from_php($sidebar, $data);
}
return self::compile($sidebar, $data);
}
/**
* Get sidebar from PHP
* @api
* @param string $sidebar
* @param array $data
* @return string
*/
public static function get_sidebar_from_php( $sidebar = '', $data ) {
$caller = LocationManager::get_calling_script_dir(1);
$uris = LocationManager::get_locations($caller);
ob_start();
$found = false;
foreach ( $uris as $uri ) {
if ( file_exists(trailingslashit($uri).$sidebar) ) {
include trailingslashit($uri).$sidebar;
$found = true;
break;
}
}
if ( !$found ) {
Helper::error_log('error loading your sidebar, check to make sure the file exists');
}
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
/* Widgets
================================ */
/**
* Get widgets.
*
* @api
* @param int|string $widget_id Optional. Index, name or ID of dynamic sidebar. Default 1.
/var/www/html/vendor/timber/timber/lib/Timber.php
public static function render_string( $string, $data = array() ) {
$compiled = self::compile_string($string, $data);
echo $compiled;
return $compiled;
}
/* Sidebar
================================ */
/**
* Get sidebar.
* @api
* @param string $sidebar
* @param array $data
* @return bool|string
*/
public static function get_sidebar( $sidebar = 'sidebar.php', $data = array() ) {
if ( strstr(strtolower($sidebar), '.php') ) {
return self::get_sidebar_from_php($sidebar, $data);
}
return self::compile($sidebar, $data);
}
/**
* Get sidebar from PHP
* @api
* @param string $sidebar
* @param array $data
* @return string
*/
public static function get_sidebar_from_php( $sidebar = '', $data ) {
$caller = LocationManager::get_calling_script_dir(1);
$uris = LocationManager::get_locations($caller);
ob_start();
$found = false;
foreach ( $uris as $uri ) {
if ( file_exists(trailingslashit($uri).$sidebar) ) {
include trailingslashit($uri).$sidebar;
$found = true;
/var/www/html/public/content/themes/pbc/single.php
<?php
/**
* The Template for displaying all single posts
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
$context = Timber::get_context();
$post = Timber::query_post();
$categories = $post->categories();
$context['post'] = new \PBC\Post($post);
$context['published_date'] = date('c',strtotime($post->post_date));
$context['modified_date'] = date('c',strtotime($post->post_modified));
$context['sidebar'] = Timber::get_sidebar('sidebar.php', $context);
if(is_singular("podcast_episodes")){
add_filter("the_content", function($content){
if(strpos($content,'div') && strpos($content,'div') < strpos($content,'img')){
return preg_replace('@(<div id="attachment_[0-9]+"[\S\s]*?</div>)@m', " ", $content,1);
}else{
return preg_replace('@(<p><img loading="lazy" class="alignnone size-full wp-image-[0-9]+"[\S\s]*?/?></p>)@m', " ", $content,1);
}
}, 100);
}
if(is_singular("post")){
add_filter("the_content", function($content){
if(strpos($content,'div') && strpos($content,'div') < strpos($content,'img')){
return preg_replace('@(<div id="attachment_[0-9]+"[\S\s]*?</div>)@m', " ", $content,1);
}else{
return preg_replace('@(<p><img loading="lazy" class="alignnone size-full wp-image-[0-9]+"[\S\s]*?/?></p>)@m', " ", $content,1);
}
}, 100);
$context['more_from'] = Timber::get_posts([
/var/www/html/public/wordpress/wp-includes/template-loader.php
}
break;
}
}
if ( ! $template ) {
$template = get_index_template();
}
/**
* Filters the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
$template = apply_filters( 'template_include', $template );
if ( $template ) {
include $template;
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
}
/var/www/html/public/wordpress/wp-blog-header.php
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}
/var/www/html/public/index.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// WordPress view bootstrapper
define( 'WP_USE_THEMES', true );
// composer auto loader, symlinks all colliding, this should resolve the relative include paths correctly
//chdir( dirname ( realpath ( __FILE__ ) ) );
//require( '../vendor/autoload.php' );
require( './wordpress/wp-blog-header.php');