/var/www/html/public/content/themes/pbc/templates/single.twig
<p id="caption-attachment-{{ post.thumbnail.id }}" class="wp-caption-text"><strong>{{ post.thumbnail.caption }}</strong></p>
</div>
{% endif %}
{% if post.category == 'Endgames' %}
<div class="puzzle-section">
{% if puzzle_embed %}
<iframe src="{{puzzle_embed}}" style="width:100%; height:1000px;" frameborder="0"></iframe>
{% else %}
{% include '@atoms/image.twig' with { item: post.custom.download_file } %}
{% endif %}
<a href="{{puzzle_embed}}" class="button puzzle--button button--offer" download>Download the puzzles here</a>
</div>
{% endif %}
{% if post.sponsored and post.sponsor_name %}
<div class="blog-header__info-box">
<p>This article was produced in association with {{ post.sponsor_name }}</p>
{% if post.sponsors_logo %}
<img src="{{ post.sponsors_logo.guid|resize(200) }}" class="blog-header__info-box__image" />
{% endif %}
</div>
{% endif %}
<div class="blog__main {{ post.thumbnail and long ? 'blog__main--longtext' : '' }}">
{{ post.content }}
</div>
{% for author in post.get_authors %}
{% include 'components/blog-byline.twig' with { author: author } %}
{% endfor %}
{% if global.enable_comments and enable_comments %}
{% include 'comment.twig' %}
{% endif %}
</div>
<aside class="blog__sidebar {{ long ? 'blog__sidebar--longread' : '' }}">
{{ sidebar }}
</aside>
/var/www/html/vendor/timber/timber/lib/ImageHelper.php
$loc = self::get_sideloaded_file_loc($file);
if ( file_exists($loc) ) {
return URLHelper::file_system_to_url($loc);
}
// Download file to temp location
if ( !function_exists('download_url') ) {
require_once ABSPATH.'/wp-admin/includes/file.php';
}
$tmp = download_url($file);
preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches);
$file_array = array();
$file_array['name'] = PathHelper::basename($matches[0]);
$file_array['tmp_name'] = $tmp;
// If error storing temporarily, do not use
if ( is_wp_error($tmp) ) {
$file_array['tmp_name'] = '';
}
// do the validation and storage stuff
$locinfo = PathHelper::pathinfo($loc);
$file = wp_upload_bits($locinfo['basename'], null, file_get_contents($file_array['tmp_name']));
// delete tmp file
@unlink($file_array['tmp_name']);
return $file['url'];
}
/**
* Takes in an URL and breaks it into components,
* that will then be used in the different steps of image processing.
* The image is expected to be either part of a theme, plugin, or an upload.
*
* @param string $url an URL (absolute or relative) pointing to an image
* @return array an array (see keys in code below)
*/
public static function analyze_url( $url ) {
$result = array(
'url' => $url, // the initial url
'absolute' => URLHelper::is_absolute($url), // is the url absolute or relative (to home_url)
'base' => 0, // is the image in uploads dir, or in content dir (theme or plugin)
'subdir' => '', // the path between base (uploads or content) and file
'filename' => '', // the filename, without extension
/var/www/html/vendor/timber/timber/lib/ImageHelper.php
$loc = self::get_sideloaded_file_loc($file);
if ( file_exists($loc) ) {
return URLHelper::file_system_to_url($loc);
}
// Download file to temp location
if ( !function_exists('download_url') ) {
require_once ABSPATH.'/wp-admin/includes/file.php';
}
$tmp = download_url($file);
preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches);
$file_array = array();
$file_array['name'] = PathHelper::basename($matches[0]);
$file_array['tmp_name'] = $tmp;
// If error storing temporarily, do not use
if ( is_wp_error($tmp) ) {
$file_array['tmp_name'] = '';
}
// do the validation and storage stuff
$locinfo = PathHelper::pathinfo($loc);
$file = wp_upload_bits($locinfo['basename'], null, file_get_contents($file_array['tmp_name']));
// delete tmp file
@unlink($file_array['tmp_name']);
return $file['url'];
}
/**
* Takes in an URL and breaks it into components,
* that will then be used in the different steps of image processing.
* The image is expected to be either part of a theme, plugin, or an upload.
*
* @param string $url an URL (absolute or relative) pointing to an image
* @return array an array (see keys in code below)
*/
public static function analyze_url( $url ) {
$result = array(
'url' => $url, // the initial url
'absolute' => URLHelper::is_absolute($url), // is the url absolute or relative (to home_url)
'base' => 0, // is the image in uploads dir, or in content dir (theme or plugin)
'subdir' => '', // the path between base (uploads or content) and file
'filename' => '', // the filename, without extension
/var/www/html/vendor/timber/timber/lib/ImageHelper.php
* @param object $op object of class TimberImageOperation
* @param boolean $force if true, remove any already existing result file and forces file generation
* @return string URL to the new image - or the source one if error
*
*/
private static function _operate( $src, $op, $force = false ) {
if ( empty($src) ) {
return '';
}
$allow_fs_write = apply_filters('timber/allow_fs_write', true);
if ( $allow_fs_write === false ) {
return $src;
}
$external = false;
// if external image, load it first
if ( URLHelper::is_external_content($src) ) {
$src = self::sideload_image($src);
$external = true;
}
// break down URL into components
$au = self::analyze_url($src);
// build URL and filenames
$new_url = self::_get_file_url(
$au['base'],
$au['subdir'],
$op->filename($au['filename'], $au['extension']),
$au['absolute']
);
$destination_path = self::_get_file_path(
$au['base'],
$au['subdir'],
$op->filename($au['filename'], $au['extension'])
);
$source_path = self::_get_file_path(
$au['base'],
/var/www/html/vendor/timber/timber/lib/ImageHelper.php
* @example
* ```twig
* <img src="{{ image.src | resize(300, 200, 'top') }}" />
* ```
* ```html
* <img src="http://example.org/wp-content/uploads/pic-300x200-c-top.jpg" />
* ```
* @return string (ex: )
*/
public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
if ( !is_numeric($w) && is_string($w) ) {
if ( $sizes = self::find_wp_dimensions($w) ) {
$w = $sizes['w'];
$h = $sizes['h'];
} else {
return $src;
}
}
$op = new Image\Operation\Resize($w, $h, $crop);
return self::_operate($src, $op, $force);
}
/**
* Find the sizes of an image based on a defined image size
* @param string $size the image size to search for
* can be WordPress-defined ("medium")
* or user-defined ("my-awesome-size")
* @return false|array {
* @type int w
* @type int h
* }
*/
private static function find_wp_dimensions( $size ) {
global $_wp_additional_image_sizes;
if ( isset($_wp_additional_image_sizes[$size]) ) {
$w = $_wp_additional_image_sizes[$size]['width'];
$h = $_wp_additional_image_sizes[$size]['height'];
} else if ( in_array($size, array('thumbnail', 'medium', 'large')) ) {
$w = get_option($size.'_size_w');
$h = get_option($size.'_size_h');
/var/www/html/vendor/twig/twig/src/Environment.php
$key = $this->cache->generateKey($name, $mainCls);
if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
$this->cache->load($key);
}
$source = null;
if (!class_exists($cls, false)) {
$source = $this->getLoader()->getSourceContext($name);
$content = $this->compileSource($source);
$this->cache->write($key, $content);
$this->cache->load($key);
if (!class_exists($mainCls, false)) {
/* Last line of defense if either $this->bcWriteCacheFile was used,
* $this->cache is implemented as a no-op or we have a race condition
* where the cache was cleared between the above calls to write to and load from
* the cache.
*/
eval('?>'.$content);
}
if (!class_exists($cls, false)) {
throw new RuntimeError(sprintf('Failed to load Twig template "%s", index "%s": cache might be corrupted.', $name, $index), -1, $source);
}
}
}
// to be removed in 3.0
$this->extensionSet->initRuntime($this);
return $this->loadedTemplates[$cls] = new $cls($this);
}
/**
* Creates a template from source.
*
* This method should not be used as a generic way to load templates.
*
* @param string $template The template source
/var/www/html/vendor/twig/twig/src/Template.php
{
if ($useBlocks && isset($blocks[$name])) {
$template = $blocks[$name][0];
$block = $blocks[$name][1];
} elseif (isset($this->blocks[$name])) {
$template = $this->blocks[$name][0];
$block = $this->blocks[$name][1];
} else {
$template = null;
$block = null;
}
// avoid RCEs when sandbox is enabled
if (null !== $template && !$template instanceof self) {
throw new \LogicException('A block must be a method on a \Twig\Template instance.');
}
if (null !== $template) {
try {
$template->$block($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($template->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getSourceContext(), $e);
$e->guess();
throw $e;
}
} elseif (false !== $parent = $this->getParent($context)) {
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false, $templateContext ?? $this);
/var/www/html/vendor/twig/twig/src/Environment.php
$key = $this->cache->generateKey($name, $mainCls);
if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
$this->cache->load($key);
}
$source = null;
if (!class_exists($cls, false)) {
$source = $this->getLoader()->getSourceContext($name);
$content = $this->compileSource($source);
$this->cache->write($key, $content);
$this->cache->load($key);
if (!class_exists($mainCls, false)) {
/* Last line of defense if either $this->bcWriteCacheFile was used,
* $this->cache is implemented as a no-op or we have a race condition
* where the cache was cleared between the above calls to write to and load from
* the cache.
*/
eval('?>'.$content);
}
if (!class_exists($cls, false)) {
throw new RuntimeError(sprintf('Failed to load Twig template "%s", index "%s": cache might be corrupted.', $name, $index), -1, $source);
}
}
}
// to be removed in 3.0
$this->extensionSet->initRuntime($this);
return $this->loadedTemplates[$cls] = new $cls($this);
}
/**
* Creates a template from source.
*
* This method should not be used as a generic way to load templates.
*
* @param string $template The template source
/var/www/html/vendor/twig/twig/src/Template.php
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
$e->guess();
throw $e;
}
}
/var/www/html/vendor/twig/twig/src/Template.php
{
return $this;
}
/**
* Returns all blocks.
*
* This method is for internal use only and should never be called
* directly.
*
* @return array An array of blocks
*/
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
/var/www/html/vendor/twig/twig/src/Environment.php
$key = $this->cache->generateKey($name, $mainCls);
if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
$this->cache->load($key);
}
$source = null;
if (!class_exists($cls, false)) {
$source = $this->getLoader()->getSourceContext($name);
$content = $this->compileSource($source);
$this->cache->write($key, $content);
$this->cache->load($key);
if (!class_exists($mainCls, false)) {
/* Last line of defense if either $this->bcWriteCacheFile was used,
* $this->cache is implemented as a no-op or we have a race condition
* where the cache was cleared between the above calls to write to and load from
* the cache.
*/
eval('?>'.$content);
}
if (!class_exists($cls, false)) {
throw new RuntimeError(sprintf('Failed to load Twig template "%s", index "%s": cache might be corrupted.', $name, $index), -1, $source);
}
}
}
// to be removed in 3.0
$this->extensionSet->initRuntime($this);
return $this->loadedTemplates[$cls] = new $cls($this);
}
/**
* Creates a template from source.
*
* This method should not be used as a generic way to load templates.
*
* @param string $template The template source
/var/www/html/vendor/twig/twig/src/Template.php
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
$e->guess();
throw $e;
}
}
/var/www/html/vendor/twig/twig/src/Template.php
{
return $this;
}
/**
* Returns all blocks.
*
* This method is for internal use only and should never be called
* directly.
*
* @return array An array of blocks
*/
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
/var/www/html/vendor/twig/twig/src/Template.php
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
/var/www/html/vendor/twig/twig/src/TemplateWrapper.php
* directly (use Twig\Environment::load() instead).
*
* @internal
*/
public function __construct(Environment $env, Template $template)
{
$this->env = $env;
$this->template = $template;
}
/**
* Renders the template.
*
* @param array $context An array of parameters to pass to the template
*/
public function render(array $context = []): string
{
// using func_get_args() allows to not expose the blocks argument
// as it should only be used by internal code
return $this->template->render($context, \func_get_args()[1] ?? []);
}
/**
* Displays the template.
*
* @param array $context An array of parameters to pass to the template
*/
public function display(array $context = [])
{
// using func_get_args() allows to not expose the blocks argument
// as it should only be used by internal code
$this->template->display($context, \func_get_args()[1] ?? []);
}
/**
* Checks if a block is defined.
*
* @param string $name The block name
* @param array $context An array of parameters to pass to the template
*/
/var/www/html/vendor/timber/timber/lib/Loader.php
$key = null;
$output = false;
if ( false !== $expires ) {
ksort($data);
$key = md5($file.json_encode($data));
$output = $this->get_cache($key, self::CACHEGROUP, $cache_mode);
}
if ( false === $output || null === $output ) {
$twig = $this->get_twig();
if ( strlen($file) ) {
$loader = $this->get_loader();
$result = $loader->getCacheKey($file);
do_action('timber_loader_render_file', $result);
}
$data = apply_filters('timber_loader_render_data', $data);
$data = apply_filters('timber/loader/render_data', $data, $file);
$template = $twig->load($file);
$output = $template->render($data);
}
if ( false !== $output && false !== $expires && null !== $key ) {
$this->delete_cache();
$this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode);
}
$output = apply_filters('timber_output', $output);
return apply_filters('timber/output', $output, $data, $file);
}
protected function delete_cache() {
Cleaner::delete_transients();
}
/**
* Get first existing template.
*
* @param array|string $templates Name(s) of the Twig template(s) to choose from.
* @return string|bool Name of chosen template, otherwise false.
*/
/var/www/html/vendor/timber/timber/lib/Timber.php
if ( $via_render ) {
$file = apply_filters('timber_render_file', $file);
} else {
$file = apply_filters('timber_compile_file', $file);
}
$output = false;
if ($file !== false) {
if ( is_null($data) ) {
$data = array();
}
if ( $via_render ) {
$data = apply_filters('timber_render_data', $data);
} else {
$data = apply_filters('timber_compile_data', $data);
}
$output = $loader->render($file, $data, $expires, $cache_mode);
} else {
if ( is_array($filenames) ) {
$filenames = implode(", ", $filenames);
}
Helper::error_log( 'Error loading your template files: '.$filenames.'. Make sure one of these files exists.' );
}
do_action('timber_compile_done');
return $output;
}
/**
* Compile a string.
*
* @api
* @example
* ```php
* $data = array(
* 'username' => 'Jane Doe',
* );
/var/www/html/vendor/timber/timber/lib/Timber.php
$twig = $dummy_loader->get_twig();
$template = $twig->createTemplate($string);
return $template->render($data);
}
/**
* Fetch function.
*
* @api
* @param array|string $filenames Name of the Twig file to render. If this is an array of files, Timber will
* render the first file that exists.
* @param array $data Optional. An array of data to use in Twig template.
* @param bool|int $expires Optional. In seconds. Use false to disable cache altogether. When passed an
* array, the first value is used for non-logged in visitors, the second for users.
* Default false.
* @param string $cache_mode Optional. Any of the cache mode constants defined in TimberLoader.
* @return bool|string The returned output.
*/
public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT ) {
$output = self::compile($filenames, $data, $expires, $cache_mode, true);
$output = apply_filters('timber_compile_result', $output);
return $output;
}
/**
* Render function.
*
* Passes data to a Twig file and echoes the output.
*
* @api
* @example
* ```php
* $context = Timber::context();
*
* Timber::render( 'index.twig', $context );
* ```
* @param array|string $filenames Name of the Twig file to render. If this is an array of files, Timber will
* render the first file that exists.
* @param array $data Optional. An array of data to use in Twig template.
* @param bool|int $expires Optional. In seconds. Use false to disable cache altogether. When passed an
/var/www/html/vendor/timber/timber/lib/Timber.php
* Passes data to a Twig file and echoes the output.
*
* @api
* @example
* ```php
* $context = Timber::context();
*
* Timber::render( 'index.twig', $context );
* ```
* @param array|string $filenames Name of the Twig file to render. If this is an array of files, Timber will
* render the first file that exists.
* @param array $data Optional. An array of data to use in Twig template.
* @param bool|int $expires Optional. In seconds. Use false to disable cache altogether. When passed an
* array, the first value is used for non-logged in visitors, the second for users.
* Default false.
* @param string $cache_mode Optional. Any of the cache mode constants defined in TimberLoader.
* @return bool|string The echoed output.
*/
public static function render( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT ) {
$output = self::fetch($filenames, $data, $expires, $cache_mode);
echo $output;
return $output;
}
/**
* Render a string with Twig variables.
*
* @api
* @example
* ```php
* $data = array(
* 'username' => 'Jane Doe',
* );
*
* Timber::render_string( 'Hi {{ username }}, I’m a string with a custom Twig variable', $data );
* ```
* @param string $string A string with Twig variables.
* @param array $data An array of data to use in Twig template.
* @return bool|string
*/
/var/www/html/public/content/themes/pbc/single.php
'post_type' => 'issues',
'post_status' => 'publish',
'posts_per_page' => 1,
'post__in' => [$met]
]);
if (!empty($issues)) {
$context['issue'] = $issues[0];
}
}
}
$context['comments_open'] = comments_open();
$check = Caffeine\Feature\Meter\FrontEnd\Checker::check();
$context['enable_comments'] = !$check['blocker'];
if ( post_password_required( $post->ID ) ) {
Timber::render( 'single-password.twig', $context );
} else {
Timber::render( array( 'single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig' ), $context );
}
/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 );
require './wordpress/wp-blog-header.php';