</section>
{# End Entry Header #}
{# Check if page is password protected #}
{% if not function( 'post_password_required', post.ID ) %}
{# Begin Entry Content #}
<section class="entry-content">
{# Begin Featured Image #}
{% if gantry.config.get('content.' ~ scope ~ '.featured-image.enabled', '1') and post.thumbnail.src %}
{% set position = (gantry.config.get('content.' ~ scope ~ '.featured-image.position', 'none') == 'none') ? '' : 'float-' ~ gantry.config.get('content.' ~ scope ~ '.featured-image.position', 'none') %}
<a href="{{ post.link }}" class="post-thumbnail" aria-hidden="true">
<img src="{{ post.thumbnail.src|resize(gantry.config.get('content.' ~ scope ~ '.featured-image.width', '1150'), gantry.config.get('content.' ~ scope ~ '.featured-image.height', '285')) }}" class="featured-image tease-featured-image {{ position }}" alt="{{ post.title }}" />
</a>
{% endif %}
{# End Featured Image #}
{# Begin Page Content #}
{{ post.content }}
{{ function('wp_link_pages', {'before': '<div class="page-links" itemprop="pagination">', 'after': '</div>', 'link_before': '<span class="page-number page-numbers">', 'link_after': '</span>', 'echo': 0}) }}
{# End Page Content #}
{# Begin Edit Link #}
{{ function('edit_post_link', __('Edit', 'g5_notio'), '<span class="edit-link">', '</span>') }}
{# End Edit Link #}
</section>
{# End Entry Content #}
{% else %}
{# Begin Password Protected Form #}
<div class="password-form">
{# Include the password form #}
{% include 'partials/password-form.html.twig' %}
</div>
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
}
return $retval;
}
/**
* Adds the implementation of a wrapped instance method to the ExtensibleObject
* @param string $method
* @return Mixin
*/
function add_wrapped_instance_method($method)
{
$retval = $this->get_wrapped_instance();
// If the wrapped instance is an ExtensibleObject, then we don't need
// to use reflection
if (!is_subclass_of($this->get_wrapped_instance(), 'ExtensibleObject')) {
$func = new ReflectionMethod($this->get_wrapped_instance(), $method);
/**
* Provides some aliases to defined methods; thanks to this a call to C_Gallery_Storage->get_thumb_url() is
* translated to C_Gallery_Storage->get_image_url('thumb').
* TODO: Remove this 'magic' method so that our code is always understandable without needing deep context
*
* @param string $method
* @param array $args
* @return mixed
* @throws Exception When method delegation fails
*/
public function __call($method, $args)
{
if (preg_match('/^get_(\\w+)_(abspath|url|dimensions|html|size_params)$/', $method, $match)) {
if (isset($match[1]) && isset($match[2]) && !$this->has_method($method)) {
$method = 'get_image_' . $match[2];
$args[] = $match[1];
return parent::__call($method, $args);
}
}
return parent::__call($method, $args);
}
/**
* For compatibility reasons, we include this method. This used to be used to get the underlying storage driver.
* Necessary for Imagify integration
*/
public function &get_wrapped_instance()
{
return $this;
}
public function initialize()
{
parent::initialize();
$this->_gallery_mapper = C_Gallery_Mapper::get_instance();
$this->_image_mapper = C_Image_Mapper::get_instance();
}
/**
* Gets an instance of the gallery storage.
*
* @param bool|string $context
* @return C_Gallery_Storage
*/
public function get_backup_url($image)
{
return $this->object->get_image_url($image, 'backup');
}
/**
* Gets the absolute path where the image is stored. Can optionally return the path for a particular sized image.
*
* @param int|object $image Image ID or image object.
* @param string $size Optional. Image size. Default = 'full'.
* @param bool $check_existance Optional. Whether to check if file exists. Default = false.
* @return string Absolute path.
*/
public function get_image_abspath($image, $size = 'full', $check_existance = false)
{
$image_id = is_numeric($image) ? $image : $image->pid;
$size = $this->object->normalize_image_size_name($size);
$key = strval($image_id) . $size;
if ($check_existance || !isset(self::$image_abspath_cache[$key])) {
$retval = $this->object->_get_computed_image_abspath($image, $size, $check_existance);
self::$image_abspath_cache[$key] = $retval;
}
$retval = self::$image_abspath_cache[$key];
return $retval;
}
/**
* Gets the url of a particular-sized image.
*
* @param int|object $image Image ID or image object.
* @param string $size Image size. Default = 'full'.
* @return string Image URL.
*/
public function get_image_url($image, $size = 'full')
{
$retval = null;
$image_id = is_numeric($image) ? $image : $image->pid;
$key = strval($image_id) . $size;
$success = true;
if (!isset(self::$image_url_cache[$key])) {
$url = $this->object->_get_computed_image_url($image, $size);
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
/**
* Provides some aliases to defined methods; thanks to this a call to C_Gallery_Storage->get_thumb_url() is
* translated to C_Gallery_Storage->get_image_url('thumb').
* TODO: Remove this 'magic' method so that our code is always understandable without needing deep context
*
* @param string $method
* @param array $args
* @return mixed
* @throws Exception When method delegation fails
*/
public function __call($method, $args)
{
if (preg_match('/^get_(\\w+)_(abspath|url|dimensions|html|size_params)$/', $method, $match)) {
if (isset($match[1]) && isset($match[2]) && !$this->has_method($method)) {
$method = 'get_image_' . $match[2];
$args[] = $match[1];
return parent::__call($method, $args);
}
}
return parent::__call($method, $args);
}
/**
* For compatibility reasons, we include this method. This used to be used to get the underlying storage driver.
* Necessary for Imagify integration
*/
public function &get_wrapped_instance()
{
return $this;
}
public function initialize()
{
parent::initialize();
$this->_gallery_mapper = C_Gallery_Mapper::get_instance();
$this->_image_mapper = C_Image_Mapper::get_instance();
}
/**
* Gets an instance of the gallery storage.
*
* @param bool|string $context
* @return C_Gallery_Storage
$retina_params = NULL;
if ($dynthumbs && $dynthumbs->is_size_dynamic($original_named_size)) {
$retina_params = $dynthumbs->get_params_from_name($original_named_size, true);
}
else {
$retina_params = $storage->get_image_size_params($image, $original_named_size);
}
if ($retina_params)
{
// We need to ensure that our original image is large enough to generate the Retina/2x image.
if (!empty($retina_params['width']))
$retina_params['width'] *= 2;
if (!empty($retina_params['height']))
$retina_params['height'] *= 2;
if (isset( $retina_params['crop_frame']))
$retina_params['crop'] = true;
// If a backup exists, we'll generate from that
if (($backup_abspath = $storage->get_image_abspath($image, 'backup', TRUE))) {
$backup_dimensions = $storage->get_image_dimensions($image, 'backup');
if (!isset($backup_dimensions['width']) || !isset($backup_dimensions['height'])) {
$size = getimagesize($backup_abspath);
if (is_array($size) && isset($size[0]) && isset($size[1])) {
$backup_dimensions['width'] = $size[0];
$backup_dimensions['height']= $size[1];
}
}
if (isset($backup_dimensions['width'])
&& isset($backup_dimensions['height'])
&& isset($retina_params['width'])
&& isset($retina_params['height']))
{
if ( $retina_params['width'] >= $backup_dimensions['width'] || $retina_params['height'] >= $backup_dimensions['height'] ) {
$retina_params['width'] = $backup_dimensions['width'];
$retina_params['height'] = $backup_dimensions['height'];
}
$retina_named_size = $dynthumbs->get_size_name( $retina_params );
}
else $retina_named_size = 'full';
<?php $this->start_element('nextgen_gallery.gallery_container', 'container', $displayed_gallery); ?>
<style type='text/css'>
#ngg-gallery-<?php echo esc_attr($displayed_gallery_id); ?> .ngg-pro-masonry-item {
margin-bottom: <?php print $padding; ?>px;
}
</style>
<div class="ngg-pro-masonry" id="ngg-gallery-<?php echo esc_attr($displayed_gallery_id); ?>">
<div class='ngg-pro-masonry-gutter' style='width: <?php print $padding; ?>px'></div>
<div class='ngg-pro-masonry-sizer' style='width: <?php print $size; ?>px'></div>
<?php
$this->start_element('nextgen_gallery.image_list_container', 'container', $images);
for ($i = 0; $i < count($images); $i++) {
$image = $images[$i];
$thumb_size = $storage->get_image_dimensions($image, $thumbnail_size_name);
$thumb_url = $storage->get_image_url($image, M_NextGen_PictureFill::get_retina_named_size($image,$thumbnail_size_name));
$this->start_element('nextgen_gallery.image_panel', 'item', $image);
$this->start_element('nextgen_gallery.image', 'item', $image); ?>
<div class='ngg-pro-masonry-item' style='height: <?php echo $thumb_size['height']; ?>px; max-width: <?php echo $thumb_size['width']; ?>px;'>
<a href="<?php echo esc_attr($storage->get_image_url($image)); ?>"
title="<?php echo esc_attr($image->description); ?>"
data-src="<?php echo esc_attr($storage->get_image_url($image)); ?>"
data-thumbnail="<?php echo esc_attr($thumb_url) ?>"
data-image-id="<?php echo esc_attr($image->{$image->id_field}); ?>"
data-title="<?php echo esc_attr($image->alttext); ?>"
data-description="<?php echo esc_attr(stripslashes($image->description)); ?>"
data-ngg-captions-nostylecopy="1"
<?php echo $effect_code ?>>
<?php M_NextGen_PictureFill::render_picture_element($image, $thumbnail_size_name)?>
</a>
</div>
<?php $this->end_element(); ?>
<?php $this->end_element(); ?>
<?php } ?>
<?php $this->end_element(); ?>
</div><?php $this->end_element(); ?>
* @return string|NULL
*/
public function render($return_output = false)
{
$element = $this->object->render_object();
$content = $this->object->rasterize_object($element);
if (!$return_output) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $content contains safe HTML from template rendering
echo $content;
}
return $content;
}
public function render_object()
{
// We use underscores to prefix local variables to avoid conflicts wth
// template vars.
$__element = $this->start_element($this->object->_template, 'template', $this->object);
$template_vars = $this->object->get_template_vars();
extract($template_vars);
include $this->object->get_template_abspath();
$this->end_element();
$displayed_gallery = $this->object->get_param('displayed_gallery');
if ($displayed_gallery && $this->object->get_param('display_type_rendering')) {
$triggers = \Imagely\NGG\DisplayedGallery\TriggerManager::get_instance();
$triggers->render($__element, $displayed_gallery);
}
return $__element;
}
/**
* Adds a template parameter
*
* @param $key
* @param $value
*/
public function set_param($key, $value)
{
$this->object->_params[$key] = $value;
}
/**
* Removes a template parameter
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
$this->_cache_method($mixin_klass, $method);
}
return $retval;
}
/**
* Provides an alternative way to call methods
*/
function call_method($method, $args=array())
{
if (method_exists($this, $method))
{
$reflection = new ReflectionMethod($this, $method);
return $reflection->invokeArgs($this, array($args));
}
else {
return $this->__call($method, $args);
}
}
/**
* Returns TRUE if the method in particular has been cached
* @param string $method
* @return type
*/
function is_cached($method)
{
return isset($this->_method_map_cache[$method]);
}
/**
* Caches the path to the extension which provides a particular method
* @param string $klass
* @param string $method
*/
$klass = $this->object->get_mixin_providing($method);
// Perform the routine described above...
$this->object->disable_mixin_for($method, $klass);
// Get the method map cache
$orig_method_map = $this->object->_method_map_cache;
$this->object->_method_map_cache = (array)C_Pope_Cache::get(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Call anchor
$args = func_get_args();
// Remove $method parameter
array_shift($args);
// Execute the method
$retval = $this->object->call_method($method, $args);
// Cache the method map for this configuration of mixins
C_Pope_Cache::set(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Re-enable mixins;
// $this->object->add_mixin($klass);
$this->object->enable_mixin_for($method, $klass);
// Restore the original method map
$this->object->_method_map_cache = $orig_method_map;
return $retval;
}
/**
* Although is is preferrable to call $this->object->method(), sometimes
* it's nice to use $this->method() instead.
if (isset($display_settings['enable_breadcrumbs']) && $display_settings['enable_breadcrumbs']) {
$retval = true;
} elseif (isset($display_settings['original_settings']) && $this->are_breadcrumbs_enabled($display_settings['original_settings'])) {
$retval = true;
}
return $retval;
}
public function get_original_album_entities($display_settings)
{
$retval = [];
if (isset($display_settings['original_album_entities'])) {
$retval = $display_settings['original_album_entities'];
} elseif (isset($display_settings['original_settings']) && $this->get_original_album_entities($display_settings['original_settings'])) {
$retval = $this->get_original_album_entities($display_settings['original_settings']);
}
return $retval;
}
public function render_object()
{
$root_element = $this->call_parent('render_object');
$displayed_gallery = $this->object->get_param('displayed_gallery');
if ($displayed_gallery) {
$ds = $displayed_gallery->display_settings;
$original_entities = $this->get_original_album_entities($ds);
if ($this->are_breadcrumbs_enabled($ds) && $original_entities) {
$original_entities = $this->get_original_album_entities($ds);
if (!empty($ds['original_album_id'])) {
$ids = $ds['original_album_id'];
} else {
$ids = $displayed_gallery->container_ids;
}
$breadcrumbs = $this->object->generate_breadcrumb($ids, $original_entities);
foreach ($root_element->find('nextgen_gallery.gallery_container', true) as $container) {
$container->insert($breadcrumbs);
}
}
}
return $root_element;
}
public function render_legacy_template_breadcrumbs($displayed_gallery, $entities, $gallery_id = false)
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
$this->_cache_method($mixin_klass, $method);
}
return $retval;
}
/**
* Provides an alternative way to call methods
*/
function call_method($method, $args=array())
{
if (method_exists($this, $method))
{
$reflection = new ReflectionMethod($this, $method);
return $reflection->invokeArgs($this, array($args));
}
else {
return $this->__call($method, $args);
}
}
/**
* Returns TRUE if the method in particular has been cached
* @param string $method
* @return type
*/
function is_cached($method)
{
return isset($this->_method_map_cache[$method]);
}
/**
* Caches the path to the extension which provides a particular method
* @param string $klass
* @param string $method
*/
$klass = $this->object->get_mixin_providing($method);
// Perform the routine described above...
$this->object->disable_mixin_for($method, $klass);
// Get the method map cache
$orig_method_map = $this->object->_method_map_cache;
$this->object->_method_map_cache = (array)C_Pope_Cache::get(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Call anchor
$args = func_get_args();
// Remove $method parameter
array_shift($args);
// Execute the method
$retval = $this->object->call_method($method, $args);
// Cache the method map for this configuration of mixins
C_Pope_Cache::set(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Re-enable mixins;
// $this->object->add_mixin($klass);
$this->object->enable_mixin_for($method, $klass);
// Restore the original method map
$this->object->_method_map_cache = $orig_method_map;
return $retval;
}
/**
* Although is is preferrable to call $this->object->method(), sometimes
* it's nice to use $this->method() instead.
* @adapts I_MVC_View
*/
class A_NextGen_Album_Descriptions extends Mixin
{
// When viewing a child gallery the album controller's add_description_to_legacy_templates() method will be
// called for the gallery and then again for the root album; we only want to run once.
public static $_description_added_once = false;
public function are_descriptions_enabled($display_settings)
{
$retval = false;
if (isset($display_settings['enable_descriptions']) && $display_settings['enable_descriptions']) {
$retval = true;
} elseif (isset($display_settings['original_settings']) && $this->are_descriptions_enabled($display_settings['original_settings'])) {
$retval = true;
}
return $retval;
}
public function render_object()
{
$root_element = $this->call_parent('render_object');
$displayed_gallery = $this->object->get_param('displayed_gallery');
if ($displayed_gallery) {
$ds = $displayed_gallery->display_settings;
if ($this->are_descriptions_enabled($ds)) {
$description = $this->object->generate_description($displayed_gallery);
foreach ($root_element->find('nextgen_gallery.gallery_container', true) as $container) {
// Determine where (to be compatible with breadcrumbs) in the container to insert.
$pos = 0;
foreach ($container->_list as $ndx => $item) {
if (is_string($item)) {
$pos = $ndx;
} else {
break;
}
}
$container->insert($description, $pos);
}
}
}
return $root_element;
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
$this->_cache_method($mixin_klass, $method);
}
return $retval;
}
/**
* Provides an alternative way to call methods
*/
function call_method($method, $args=array())
{
if (method_exists($this, $method))
{
$reflection = new ReflectionMethod($this, $method);
return $reflection->invokeArgs($this, array($args));
}
else {
return $this->__call($method, $args);
}
}
/**
* Returns TRUE if the method in particular has been cached
* @param string $method
* @return type
*/
function is_cached($method)
{
return isset($this->_method_map_cache[$method]);
}
/**
* Caches the path to the extension which provides a particular method
* @param string $klass
* @param string $method
*/
$klass = $this->object->get_mixin_providing($method);
// Perform the routine described above...
$this->object->disable_mixin_for($method, $klass);
// Get the method map cache
$orig_method_map = $this->object->_method_map_cache;
$this->object->_method_map_cache = (array)C_Pope_Cache::get(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Call anchor
$args = func_get_args();
// Remove $method parameter
array_shift($args);
// Execute the method
$retval = $this->object->call_method($method, $args);
// Cache the method map for this configuration of mixins
C_Pope_Cache::set(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Re-enable mixins;
// $this->object->add_mixin($klass);
$this->object->enable_mixin_for($method, $klass);
// Restore the original method map
$this->object->_method_map_cache = $orig_method_map;
return $retval;
}
/**
* Although is is preferrable to call $this->object->method(), sometimes
* it's nice to use $this->method() instead.
* @param $display_settings
* @return bool
*/
public static function are_child_entities_enabled($display_settings)
{
$retval = false;
if (empty($display_settings['open_gallery_in_lightbox'])) {
$display_settings['open_gallery_in_lightbox'] = 0;
}
if ($display_settings['open_gallery_in_lightbox'] == 1) {
$retval = true;
}
return $retval;
}
/**
* Search inside the template for the inside of the container and append our inline JS
*/
public function render_object()
{
$root_element = $this->call_parent('render_object');
$displayed_gallery = $this->object->get_param('displayed_gallery');
if ($displayed_gallery) {
if (!$this->is_basic_album($displayed_gallery)) {
return $root_element;
}
$ds = $displayed_gallery->display_settings;
if (self::are_child_entities_enabled($ds)) {
$id = $displayed_gallery->ID();
foreach ($root_element->find('nextgen_gallery.gallery_container', true) as $container) {
$container->append(self::generate_script(self::$_entities[$id]));
}
}
}
return $root_element;
}
/**
* Generate the JS that will be inserted into the template. This method static for the basic album controller to access.
*
* @param array $galleries
* @return string
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
$this->_cache_method($mixin_klass, $method);
}
return $retval;
}
/**
* Provides an alternative way to call methods
*/
function call_method($method, $args=array())
{
if (method_exists($this, $method))
{
$reflection = new ReflectionMethod($this, $method);
return $reflection->invokeArgs($this, array($args));
}
else {
return $this->__call($method, $args);
}
}
/**
* Returns TRUE if the method in particular has been cached
* @param string $method
* @return type
*/
function is_cached($method)
{
return isset($this->_method_map_cache[$method]);
}
/**
* Caches the path to the extension which provides a particular method
* @param string $klass
* @param string $method
*/
$klass = $this->object->get_mixin_providing($method);
// Perform the routine described above...
$this->object->disable_mixin_for($method, $klass);
// Get the method map cache
$orig_method_map = $this->object->_method_map_cache;
$this->object->_method_map_cache = (array)C_Pope_Cache::get(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Call anchor
$args = func_get_args();
// Remove $method parameter
array_shift($args);
// Execute the method
$retval = $this->object->call_method($method, $args);
// Cache the method map for this configuration of mixins
C_Pope_Cache::set(
array($this->object->context, $this->object->_mixin_priorities, $this->object->_disabled_map),
$this->object->_method_map_cache
);
// Re-enable mixins;
// $this->object->add_mixin($klass);
$this->object->enable_mixin_for($method, $klass);
// Restore the original method map
$this->object->_method_map_cache = $orig_method_map;
return $retval;
}
/**
* Although is is preferrable to call $this->object->method(), sometimes
* it's nice to use $this->method() instead.
* @param $display_settings
* @return bool
*/
function are_child_entities_enabled($display_settings)
{
$retval = FALSE;
if (empty($display_settings['open_gallery_in_lightbox'])) {
$display_settings['open_gallery_in_lightbox'] = 0;
}
if ($display_settings['open_gallery_in_lightbox'] == 1) {
$retval = TRUE;
}
return $retval;
}
/**
* Search inside the template for the inside of the container and append our inline JS
*/
function render_object()
{
$root_element = $this->call_parent('render_object');
if ($displayed_gallery = $this->object->get_param('displayed_gallery')) {
if (!$this->is_pro_album($displayed_gallery)) {
return $root_element;
}
$ds = $displayed_gallery->display_settings;
if ($this->are_child_entities_enabled($ds)) {
$id = $displayed_gallery->ID();
foreach ($root_element->find('nextgen_gallery.gallery_container', TRUE) as $container) {
$container->append($this->object->generate_script(self::$_entities[$id]));
}
}
}
return $root_element;
}
/**
* Generate the JS that will be inserted into the template
*
* @param array $galleries
* @return string
*/
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
return $retval;
}
}
/**
* MVC view instance methods mixin.
*
* Provides instance methods for MVC views.
*/
class Mixin_Mvc_View_Instance_Methods extends Mixin
{
// phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound
/**
* Renders the view (template)
*
* @param bool $return_output (optional).
* @return string|NULL
*/
public function render($return_output = false)
{
$element = $this->object->render_object();
$content = $this->object->rasterize_object($element);
if (!$return_output) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $content contains safe HTML from template rendering
echo $content;
}
return $content;
}
public function render_object()
{
// We use underscores to prefix local variables to avoid conflicts wth
// template vars.
$__element = $this->start_element($this->object->_template, 'template', $this->object);
$template_vars = $this->object->get_template_vars();
extract($template_vars);
include $this->object->get_template_abspath();
$this->end_element();
$displayed_gallery = $this->object->get_param('displayed_gallery');
if ($displayed_gallery && $this->object->get_param('display_type_rendering')) {
$triggers = \Imagely\NGG\DisplayedGallery\TriggerManager::get_instance();
$triggers->render($__element, $displayed_gallery);
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
}
/**
* Renders a partial template.
*
* @param string $template Path to the POPE module#filename.
* @param array $params Array of parameters to be extract()ed to the template file.
* @param bool $return_output When true results will be returned instead of printed.
* @param null $context Application context.
* @param string $new_template_path Path to the new non-POPE file located under the plugin root's '/templates' directory.
* @return mixed
*/
public function render_partial($template, $params = array(), $return_output = false, $context = null, $new_template_path = '')
{
/**
* View instance.
*
* @var C_MVC_View $view
*/
$view = $this->object->create_view($template, $params, $context, $new_template_path);
return $view->render($return_output);
}
}
/**
* MVC controller instance methods mixin.
*
* Adds methods for MVC Controller
*
* @property C_MVC_Controller $object
*/
class Mixin_MVC_Controller_Instance_Methods extends Mixin
{
// phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound
// Provide a default view.
public function index_action($return_output = false)
{
return $this->render_view('photocrati-mvc#index', [], $return_output);
}
/**
* Returns the value of a parameters
*
* @param string $path
* @param string|false $module (optional).
* @return string
*/
public function get_static_url($path, $module = false)
{
return \Imagely\NGG\Display\StaticPopeAssets::get_url($path, $module);
}
/**
* Renders a template and outputs the response headers
*
* @param string $name
* @param array $vars (optional).
* @param bool $return_output (optional).
* @return string
*/
public function render_view($name, $vars = array(), $return_output = false)
{
$this->object->render();
return $this->object->render_partial($name, $vars, $return_output);
}
/**
* Renders a partial template.
*
* @param string $template Path to the POPE module#filename.
* @param array $params Array of parameters to be extract()ed to the template file.
* @param bool $return_output When true results will be returned instead of printed.
* @param null $context Application context.
* @param string $new_template_path Path to the new non-POPE file located under the plugin root's '/templates' directory.
* @return mixed
*/
public function render_partial($template, $params = array(), $return_output = false, $context = null, $new_template_path = '')
{
/**
* View instance.
*
* @var C_MVC_View $view
*/
$view = $this->object->create_view($template, $params, $context, $new_template_path);
return $view->render($return_output);
* @param bool $return
* @return string
*/
function index_action($displayed_gallery, $return = FALSE)
{
$images = $displayed_gallery->get_included_entities();
// This display type was never meant to work with NextGen's trigger icons but the setting was set to 'always' as
// a default value in the pro-masonry-mapper. Prevent users from getting an improperly rendered gallery trigger:
$displayed_gallery->display_settings['ngg_triggers_display'] = 'never';
if (!$images) {
return $this->object->render_partial("photocrati-nextgen_gallery_display#no_images_found", array(), $return);
} else {
$params = $displayed_gallery->display_settings;
$params['images'] = $images;
$params['storage'] = C_Gallery_Storage::get_instance();
$params['effect_code'] = $this->object->get_effect_code($displayed_gallery);
$params['displayed_gallery_id'] = $displayed_gallery->id();
$params['thumbnail_size_name'] = C_Dynamic_Thumbnails_Manager::get_instance()->get_size_name(array('width' => $params['size'], 'crop' => FALSE));
$params = $this->object->prepare_display_parameters($displayed_gallery, $params);
return $this->object->render_view('photocrati-nextgen_pro_masonry#index', $params, $return);
}
}
/**
* Enqueues all static resources required by this display type
*
* @param C_Displayed_Gallery $displayed_gallery
*/
function enqueue_frontend_resources($displayed_gallery)
{
global $wp_version;
wp_enqueue_style('nextgen_pro_masonry_style', $this->get_static_url('photocrati-nextgen_pro_masonry#style.css'));
// Wordpress prior to 3.9 included an older version of Masonry than we wanted.
if ($wp_version >= 3.9) {
wp_enqueue_script('nextgen_pro_masonry_script', $this->get_static_url('photocrati-nextgen_pro_masonry#nextgen_pro_masonry.js'), array('jquery', 'masonry', 'ngg_waitforimages'));
} else {
// When we began pro-masonry development Wordpress did not yet include Masonry; when they did include it
// it was an older version than what NextGEN Pro had shipped with.
//
// For compatibility with <= 3.8 sites sites we use a different startup script and localize some settings
if (wp_script_is('jquery-masonry', 'enqueued')) {
elseif ($this->is_wrapper() && $this->wrapped_class_provides($method)) {
$retval = TRUE;
}
return $retval;
}
/**
* Executes a cached method
* @param string $method
* @param array $args
* @return mixed
*/
function _exec_cached_method($method, $args=array())
{
$klass = $this->_method_map_cache[$method];
$object = $this->_instantiate_mixin($klass);
$object->object = $this;
$reflection = new ReflectionMethod($object, $method);
return $reflection->invokeArgs($object, $args);
}
/**
* Returns TRUE if the ExtensibleObject has decided to implement a
* particular interface
* @param string $interface
* @return boolean
*/
function implements_interface($interface)
{
return in_array($interface, $this->_interfaces);
}
function get_class_definition_dir($parent=FALSE)
{
return dirname($this->get_class_definition_file($parent));
}
function get_class_definition_file($parent=FALSE)
{
* 1) Execute all global pre-hooks and any pre-hooks specific to the requested
* method. Each method call has instance properties that can be set by
* other hooks to modify the execution. For example, a pre hook can
* change the 'run_pre_hooks' property to be false, which will ensure that
* all other pre hooks will NOT be executed.
* 2) Runs the method. Checks whether the path to the method has been cached
* 3) Execute all global post-hooks and any post-hooks specific to the
* requested method. Post hooks can access method properties as well. A
* common usecase is to return the value of a post hook instead of the
* actual method call. To do this, set the 'return_value' property.
* @param string $method
* @param array $args
* @return mixed
*/
function __call($method, $args)
{
$retval = NULL;
if (($this->get_mixin_providing($method))) {
$retval = $this->_exec_cached_method($method, $args);
}
// This is NOT a wrapped class, and no extensions provide the method
else {
// Perhaps this is a wrapper and the wrapped object
// provides this method
if ($this->is_wrapper() && $this->wrapped_class_provides($method))
{
$object = $this->add_wrapped_instance_method($method);
$retval = call_user_func_array(
array(&$object, $method),
$args
);
}
elseif ($this->_throw_error) {
$klass = function_exists('get_called_class') ? get_called_class() : get_class();
if (defined('POPE_DEBUG') && constant('POPE_DEBUG'))
print_r(debug_backtrace());
throw new Exception("`{$method}` not defined for {$klass}");
}
// TODO: This is hack. We need to figure out a more uniform way of detecting dynamic image urls.
if ( strpos( $html, Settings::get_instance()->get( 'dynamic_thumbnail_slug' ) . '/' ) !== false ) {
$html = false; // forces the cache to be re-generated.
}
// Output debug messages.
if ( $html ) {
$retval .= $this->debug_msg( 'HIT!' );
} else {
$retval .= $this->debug_msg( 'MISS!' );
}
// If a cached version doesn't exist, then create the cache.
if ( ! $html ) {
$retval .= $this->debug_msg( 'Rendering displayed gallery' );
$html = apply_filters(
'ngg_displayed_gallery_rendering',
$controller->index_action( $displayed_gallery, true ),
$displayed_gallery
);
if ( $key != null ) {
Transient::update( $key, $html, NGG_RENDERING_CACHE_TTL );
}
}
$retval .= $html;
if ( ! $return_output ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $retval contains safe HTML from gallery rendering
echo $retval;
}
return $retval;
}
public function do_app_rewrites( $displayed_gallery ) {
if ( self::$has_done_app_rewrite ) {
* @param array|DisplayedGallery $params_or_dg
* @param null|string $inner_content (optional)
* @return string
*/
public function display_images( $params_or_dg, $inner_content = null ) {
// Convert the array of parameters into a displayed gallery.
if ( is_array( $params_or_dg ) ) {
$params = $params_or_dg;
$displayed_gallery = $this->params_to_displayed_gallery( $params );
} elseif ( is_object( $params_or_dg ) && get_class( $params_or_dg ) === 'Imagely\NGG\DataTypes\DisplayedGallery' ) {
// We've already been given a displayed gallery.
$displayed_gallery = $params_or_dg;
} else {
// Something has gone wrong; the request cannot be rendered.
$displayed_gallery = null;
}
// Validate the displayed gallery.
if ( $displayed_gallery && $displayed_gallery->validation() ) {
$retval = $this->render( $displayed_gallery, true );
} elseif ( \C_NextGEN_Bootstrap::$debug ) {
$retval = __( 'We cannot display this gallery', 'nggallery' ) . $this->debug_msg( $displayed_gallery->validation() ) . $this->debug_msg( $displayed_gallery->get_entity() );
} else {
$retval = __( 'We cannot display this gallery', 'nggallery' );
}
return $retval;
}
public function debug_msg( $msg, $print_r = false ) {
$retval = '';
if ( \C_NextGEN_Bootstrap::$debug ) {
ob_start();
if ( $print_r ) {
echo '<pre>';
print_r( $msg );
echo '</pre>';
} else {
// phpcs:ignore Squiz.PHP.CommentedOutCode.Found -- Debug code intentionally commented out.
'wp_plugins_url' => $router->get_base_url( 'plugins' ),
'wp_content_url' => $router->get_base_url( 'content' ),
'wp_includes_url' => includes_url(),
'ngg_param_slug' => $settings->get( 'router_param_slug', 'nggallery' ),
'rest_nonce' => wp_create_nonce( 'wp_rest' ),
];
\wp_localize_script( 'photocrati_ajax', 'photocrati_ajax', $vars );
}
/**
* Provides the [ngg] and [ngg_images] shortcodes
*
* @param array $params Display parameters.
* @param string $inner_content Inner shortcode content.
* @return string
*/
public function display_images( $params, $inner_content = null ) {
$renderer = Renderer::get_instance();
return $renderer->display_images( $params, $inner_content );
}
/**
* Gets a list of directories in which display type template might be stored
*
* @param DisplayType|string $display_type The display type object or name.
* @return array
*/
public static function get_display_type_view_dirs( $display_type ) {
if ( is_string( $display_type ) ) {
$display_type = DisplayTypeMapper::get_instance()->find_by_name( $display_type );
}
// Create an array of directories to scan.
$dirs = [];
if ( ControllerFactory::has_controller( $display_type->name ) ) {
$controller = ControllerFactory::get_controller( $display_type->name );
$dirs['default'] = $controller->get_template_directory_abspath();
}
/**
* Renders a shortcode
*
* @param string $shortcode The shortcode name.
* @param array $params The shortcode parameters.
* @param string $inner_content The inner content.
* @return string
*/
public function render_shortcode( $shortcode, $params = [], $inner_content = '' ) {
if ( isset( $this->_shortcodes[ $shortcode ] ) ) {
$shortcode = $this->_shortcodes[ $shortcode ];
if ( \is_callable( $shortcode['transformer'] ) ) {
$params = \call_user_func( $shortcode['transformer'], $params );
}
$method = ( \is_null( $shortcode['callback'] ) && \is_callable( $shortcode['transformer'] ) ) ? [ $this, 'render_legacy_shortcode' ] : $shortcode['callback'];
$retval = \call_user_func( $method, $params, $inner_content );
} else {
$retval = 'Invalid shortcode';
}
return $retval;
}
/**
* Prevents wptexturize
*
* @param string $shortcode The shortcode name.
* @param array $params The shortcode parameters.
* @param string $inner_content The inner content.
* @return mixed|void
*/
public function replace_with_placeholder( $shortcode, $params = [], $inner_content = '' ) {
$id = \count( $this->_found );
$this->_found[ $id ] = [
'shortcode' => $shortcode,
'params' => $params,
/**
* Renders a legacy shortcode
*
* @param array $params The shortcode parameters.
* @param string $inner_content The inner content.
* @return string
*/
public function render_legacy_shortcode( $params, $inner_content ) {
return Renderer::get_instance()->display_images( $params, $inner_content );
}
/**
* Executes a found shortcode by ID
*
* @param int $found_id The ID of the found shortcode.
* @return string
*/
public function execute_found_shortcode( $found_id ) {
return isset( $this->_found[ $found_id ] )
? $this->render_shortcode(
$this->_found[ $found_id ]['shortcode'],
$this->_found[ $found_id ]['params'],
$this->_found[ $found_id ]['inner_content']
)
: 'Invalid shortcode';
}
/**
* Adds a shortcode
*
* @param string $name The shortcode name.
* @param callable $callback The callback function.
* @param callable|null $transformer Parameters transformer.
* @return void
*/
public function add_shortcode( $name, $callback, $transformer = null ) {
$this->_shortcodes[ $name ] = [
'callback' => $callback,
'transformer' => $transformer,
];
* @param string $content The content to parse.
* @return string
*/
public function parse_content( $content ) {
$regex = \str_replace( '%d', '(\d+)', $this->_placeholder_text );
if ( $this->is_rest_request() ) {
// Return early if we're in the REST API and shortcodes are disabled.
// Allows other plugins to disable shortcodes in the REST API.
if ( \apply_filters( 'ngg_disable_shortcodes_in_request_api', true ) ) {
return $content;
}
\ob_start();
}
if ( \preg_match_all( "/{$regex}/m", $content, $matches, PREG_SET_ORDER ) ) {
foreach ( $matches as $match ) {
$placeholder = \array_shift( $match );
$id = \array_shift( $match );
$content = \str_replace( $placeholder, $this->execute_found_shortcode( $id ), $content );
}
}
if ( $this->is_rest_request() ) {
// Pre-generating displayed gallery cache by executing shortcodes in the REST API can prevent users
// from being able to add and save blocks with lots of images and no pagination (for example a very large
// basic slideshow or pro masonry / mosaic / tile display).
if ( \apply_filters( 'ngg_disable_shortcodes_in_request_api', false ) ) {
return $content;
}
\ob_start();
}
return $content;
}
/**
* Renders a legacy shortcode
*
* @param array $params The shortcode parameters.
$this->iterations[ $nesting_level ] = $this->priorities;
$num_args = count( $args );
do {
$this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );
$priority = $this->current_priority[ $nesting_level ];
foreach ( $this->callbacks[ $priority ] as $the_ ) {
if ( ! $this->doing_action ) {
$args[0] = $value;
}
// Avoid the array_slice() if possible.
if ( 0 === $the_['accepted_args'] ) {
$value = call_user_func( $the_['function'] );
} elseif ( $the_['accepted_args'] >= $num_args ) {
$value = call_user_func_array( $the_['function'], $args );
} else {
$value = call_user_func_array( $the_['function'], array_slice( $args, 0, $the_['accepted_args'] ) );
}
}
} while ( false !== next( $this->iterations[ $nesting_level ] ) );
unset( $this->iterations[ $nesting_level ] );
unset( $this->current_priority[ $nesting_level ] );
--$this->nesting_level;
return $value;
}
/**
* Calls the callback functions that have been added to an action hook.
*
* @since 4.7.0
*
* @param array $args Parameters to pass to the callback functions.
$all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
_wp_call_all_hook( $all_args );
}
if ( ! isset( $wp_filter[ $hook_name ] ) ) {
if ( isset( $wp_filter['all'] ) ) {
array_pop( $wp_current_filter );
}
return $value;
}
if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $hook_name;
}
// Pass the value to WP_Hook.
array_unshift( $args, $value );
$filtered = $wp_filter[ $hook_name ]->apply_filters( $value, $args );
array_pop( $wp_current_filter );
return $filtered;
}
/**
* Calls the callback functions that have been added to a filter hook, specifying arguments in an array.
*
* @since 3.0.0
*
* @see apply_filters() This function is identical, but the arguments passed to the
* functions hooked to `$hook_name` are supplied using an array.
*
* @global WP_Hook[] $wp_filter Stores all of the filters and actions.
* @global int[] $wp_filters Stores the number of times each filter was triggered.
* @global string[] $wp_current_filter Stores the list of current filters with the current one last.
*
* @param string $hook_name The name of the filter hook.
* @param array $args The arguments supplied to the functions hooked to `$hook_name`.
}
if ( $form = $this->maybe_show_password_form() ) {
return $form;
}
if ( $len == -1 && $page == 0 && $this->___content ) {
return $this->___content;
}
$content = $this->post_content;
if ( $len > 0 ) {
$content = wp_trim_words($content, $len);
}
if ( $page ) {
$contents = explode('<!--nextpage-->', $content);
$page--;
if ( count($contents) > $page ) {
$content = $contents[$page];
}
}
$content = $this->content_handle_no_teaser_block( $content );
$content = apply_filters('the_content', ($content));
if ( $len == -1 && $page == 0 ) {
$this->___content = $content;
}
return $content;
}
/**
* Handles for an circumstance with the Block editor where a "more" block has an option to
* "Hide the excerpt on the full content page" which hides everything prior to the inserted
* "more" block
* @ticket #2218
* @param string $content
* @return string
*/
protected function content_handle_no_teaser_block( $content ) {
if ( (strpos($content, 'noTeaser:true') !== false || strpos($content, '"noTeaser":true') !== false) && strpos($content, '<!-- /wp:more -->') !== false) {
$arr = explode('<!-- /wp:more -->', $content);
return trim($arr[1]);
}
return $content;
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
return;
}
throw new RuntimeError(sprintf('Neither the property "%1$s" nor one of the methods "%1$s()", "get%1$s()"/"is%1$s()" or "__call()" exist and have public access in class "%2$s".', $item, $class), -1, $this->getSourceContext());
}
if ($isDefinedTest) {
return true;
}
if ($this->env->hasExtension('\Twig\Extension\SandboxExtension')) {
$this->env->getExtension('\Twig\Extension\SandboxExtension')->checkMethodAllowed($object, $method);
}
// Some objects throw exceptions when they have __call, and the method we try
// to call is not supported. If ignoreStrictCheck is true, we should return null.
try {
if (!$arguments) {
$ret = $object->$method();
} else {
$ret = \call_user_func_array([$object, $method], $arguments);
}
} catch (\BadMethodCallException $e) {
if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
return;
}
throw $e;
}
// @deprecated in 1.28
if ($object instanceof \Twig_TemplateInterface) {
$self = $object->getTemplateName() === $this->getTemplateName();
$message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName());
if ('renderBlock' === $method || 'displayBlock' === $method) {
$message .= sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template');
} elseif ('hasBlock' === $method) {
$message .= sprintf(' Use "block("%s"%s) is defined" instead).', $arguments[0], $self ? '' : ', template');
} elseif ('render' === $method || 'display' === $method) {
$message .= sprintf(' Use include("%s") instead).', $object->getTemplateName());
echo "\" class=\"post-thumbnail\" aria-hidden=\"true\">
<img src=\"";
// line 41
echo Timber\ImageHelper::resize($this->getAttribute($this->getAttribute(($context["post"] ?? null), "thumbnail", []), "src", []), $this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "config", []), "get", [0 => (("content." . ($context["scope"] ?? null)) . ".featured-image.width"), 1 => "1150"], "method"), $this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "config", []), "get", [0 => (("content." . ($context["scope"] ?? null)) . ".featured-image.height"), 1 => "285"], "method"));
echo "\" class=\"featured-image tease-featured-image ";
echo ($context["position"] ?? null);
echo "\" alt=\"";
echo $this->getAttribute(($context["post"] ?? null), "title", []);
echo "\" />
</a>
";
}
// line 44
echo " ";
// line 45
echo "
";
// line 47
echo " ";
echo $this->getAttribute(($context["post"] ?? null), "content", []);
echo "
";
// line 49
echo call_user_func_array($this->env->getFunction('function')->getCallable(), ["wp_link_pages", ["before" => "<div class=\"page-links\" itemprop=\"pagination\">", "after" => "</div>", "link_before" => "<span class=\"page-number page-numbers\">", "link_after" => "</span>", "echo" => 0]]);
echo "
";
// line 51
echo "
";
// line 53
echo " ";
echo call_user_func_array($this->env->getFunction('function')->getCallable(), ["edit_post_link", __("Edit", "g5_notio"), "<span class=\"edit-link\">", "</span>"]);
echo "
";
// line 55
echo "
</section>
";
// line 58
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);
$this->blocks = [
'content' => [$this, 'block_content'],
];
}
protected function doDisplay(array $context, array $blocks = [])
{
// line 1
echo "<article class=\"post-type-";
echo $this->getAttribute(($context["post"] ?? null), "post_type", []);
echo " ";
echo $this->getAttribute(($context["post"] ?? null), "class", []);
echo "\" id=\"post-";
echo $this->getAttribute(($context["post"] ?? null), "ID", []);
echo "\">
";
// line 3
$this->displayBlock('content', $context, $blocks);
// line 73
echo "
</article>
";
}
// line 3
public function block_content($context, array $blocks = [])
{
// line 4
echo "
";
// line 6
echo " <section class=\"entry-header\">
";
// line 8
if ($this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "config", []), "get", [0 => (("content." . ($context["scope"] ?? null)) . ".title.enabled"), 1 => "1"], "method")) {
// line 9
echo " ";
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} 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;
}
}
{
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 (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
$context["twigTemplate"] = "page.html.twig";
// line 3
$context["scope"] = "page";
// line 1
$this->parent = $this->loadTemplate("partials/page.html.twig", "page.html.twig", 1);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 5
public function block_content($context, array $blocks = [])
{
// line 6
echo "
<div class=\"platform-content\">
<div class=\"content-wrapper\">
<section class=\"entry\">
";
// line 11
$this->loadTemplate([0 => (("partials/content-" . ($context["scope"] ?? null)) . ".html.twig"), 1 => "partials/content.html.twig"], "page.html.twig", 11)->display($context);
// line 12
echo "
</section>
</div> <!-- /content-wrapper -->
</div>
";
}
public function getTemplateName()
{
return "page.html.twig";
}
public function isTraitable()
{
return false;
}
public function getDebugInfo()
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);
}
protected function doDisplay(array $context, array $blocks = [])
{
// line 1
$this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "debugger", []), "startTimer", [0 => "render", 1 => "Rendering page"], "method");
// line 2
$this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "setLayout", [], "method");
// line 3
$this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "loadAtoms", [], "method");
// line 4
$context["segments"] = $this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "segments", [], "method");
// line 6
ob_start(function () { return ''; });
// line 7
echo " ";
if ($this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "hasContent", [], "method")) {
// line 8
echo " ";
$this->displayBlock('content', $context, $blocks);
// line 10
echo " ";
}
$context["content"] = ('' === $tmp = ob_get_clean()) ? '' : new Markup($tmp, $this->env->getCharset());
// line 13
$context["offcanvas"] = null;
// line 14
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(($context["segments"] ?? null));
foreach ($context['_seq'] as $context["_key"] => $context["segment"]) {
// line 15
echo " ";
if (($this->getAttribute($context["segment"], "type", []) == "offcanvas")) {
// line 16
$context["offcanvas"] = $context["segment"];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['segment'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} 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;
}
}
{
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 (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
public function __construct(Environment $env)
{
parent::__construct($env);
$this->blocks = [
'page_head' => [$this, 'block_page_head'],
'page_footer' => [$this, 'block_page_footer'],
];
}
protected function doGetParent(array $context)
{
// line 1
return "@nucleus/page.html.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
$this->parent = $this->loadTemplate("@nucleus/page.html.twig", "partials/page.html.twig", 1);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 3
public function block_page_head($context, array $blocks = [])
{
// line 4
if (($context["page_head"] ?? null)) {
// line 5
echo " ";
echo ($context["page_head"] ?? null);
echo "
";
} else {
// line 7
echo " ";
$this->displayParentBlock("page_head", $context, $blocks);
echo "
";
}
}
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} 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;
}
}
{
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 (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
$this->blocks = [
'content' => [$this, 'block_content'],
];
}
protected function doGetParent(array $context)
{
// line 1
return "partials/page.html.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
// line 2
$context["twigTemplate"] = "page.html.twig";
// line 3
$context["scope"] = "page";
// line 1
$this->parent = $this->loadTemplate("partials/page.html.twig", "page.html.twig", 1);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 5
public function block_content($context, array $blocks = [])
{
// line 6
echo "
<div class=\"platform-content\">
<div class=\"content-wrapper\">
<section class=\"entry\">
";
// line 11
$this->loadTemplate([0 => (("partials/content-" . ($context["scope"] ?? null)) . ".html.twig"), 1 => "partials/content.html.twig"], "page.html.twig", 11)->display($context);
// line 12
echo "
</section>
</div> <!-- /content-wrapper -->
</div>
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} 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;
}
}
{
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 (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
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 (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} 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 {
* @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
*
* @return string The rendered template
*/
public function render($context = [])
{
// 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_num_args() > 1 ? func_get_arg(1) : []);
}
/**
* Displays the template.
*
* @param array $context An array of parameters to pass to the template
*/
public function display($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_num_args() > 1 ? func_get_arg(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
*
$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.
*/
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',
* );
$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
* 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
*/
*
* To generate specific templates for your pages you can use:
* /mytheme/views/page-mypage.html.twig
* (which will still route through this PHP file)
* OR
* /mytheme/page-mypage.php
* (in which case you'll want to duplicate this file and save to the above path)
*/
$gantry = Gantry\Framework\Gantry::instance();
$theme = $gantry['theme'];
// We need to render contents of <head> before plugin content gets added.
$context = Timber::get_context();
$context['page_head'] = $theme->render('partials/page_head.html.twig', $context);
$post = Timber::query_post();
$context['post'] = $post;
Timber::render(['page-' . $post->post_name . '.html.twig', 'page.html.twig'], $context);
*/
$template = apply_filters( 'template_include', $template );
$is_stringy = is_string( $template ) || ( is_object( $template ) && method_exists( $template, '__toString' ) );
$template = $is_stringy ? realpath( (string) $template ) : null;
if (
is_string( $template ) &&
( str_ends_with( $template, '.php' ) || str_ends_with( $template, '.html' ) ) &&
is_file( $template ) &&
is_readable( $template )
) {
/**
* Fires immediately before including the template.
*
* @since 6.9.0
*
* @param string $template The path of the template about to be included.
*/
do_action( 'wp_before_include_template', $template );
include $template;
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
}
<?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';
}
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';