</section>
{# End Entry Header #}
{# Check if post 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.paged_content }}
{{ function('wp_link_pages', {'before': '<div class="page-links" itemprop="pagination"><ul class="pagination-list">', 'after': '</ul></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 #}
{# Begin Comments #}
{% if (post.comment_status == 'open' or post.comment_count > 0) and post.post_type != 'product' %}
{{ function('comments_template') }}
{% endif %}
{# End Comments #}
{% else %}
{# Begin Password Protected Form #}
$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
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);
if ($url) {
self::$image_url_cache[$key] = $url;
$success = true;
} else {
$success = false;
}
}
if ($success) {
$retval = self::$image_url_cache[$key];
} else {
$dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance();
if ($dynthumbs->is_size_dynamic($size)) {
$params = $dynthumbs->get_params_from_name($size);
$retval = \Imagely\NGG\Util\Router::get_instance()->get_url($dynthumbs->get_image_uri($image, $params), false, 'root');
}
}
return apply_filters('ngg_get_image_url', $retval, $image, $size);
}
/**
* An alias for get_full_abspath().
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
echo $retval;
return $retval;
}
static function prepare_picture_element($image, $params_or_named_size, $attrs = array())
{
$retval = array();
$dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance();
$storage = C_Gallery_Storage::get_instance();
$sources = array();
$srcsets = array();
$srcsets2 = array(); // returned unprocessed, unlike srcsets above
// Get the named size to display
$named_size = $params_or_named_size;
if (is_array($params_or_named_size))
$named_size = $dynthumbs->get_size_name($params_or_named_size);
$image_url = str_replace(' ', '%20', $storage->get_image_url($image, $named_size, TRUE));
// Get retina named size to display
$retina_named_size = self::get_retina_named_size($image, $named_size);
$retina_url = str_replace(' ', '%20', $storage->get_image_url($image, $retina_named_size));
// Set attributes
$srcsets[] = isset($_REQUEST['force_retina']) ? $retina_url : $image_url;
$srcsets2['original'] = isset($_REQUEST['force_retina']) ? $retina_url : $image_url;
$dimensions = $storage->get_image_dimensions($image, $named_size);
if (!array_key_exists('title', $attrs)) $attrs['title'] = $image->alttext;
if (!array_key_exists('alt', $attrs)) $attrs['alt'] = $image->alttext;
if ($dimensions && isset($dimensions['width']) && isset($dimensions['height']))
{
if (!array_key_exists('width', $attrs)) $attrs['width'] = $dimensions['width'];
if (!array_key_exists('height', $attrs)) $attrs['height'] = $dimensions['height'];
if (!array_key_exists('style', $attrs)) $attrs['style'] = "max-width:{$attrs['width']}px;max-height:{$attrs['height']}px";
}
// Add sources
FALSE
);
}
static function format_entities($entities = array(), $size_name = 'full', $thumbnail_size_name = 'thumb')
{
$retval = array();
if (!empty($entities))
{
$storage = C_Gallery_Storage::get_instance();
foreach ($entities as $entity) {
if (isset($entity->is_gallery) && !$entity->is_gallery)
continue;
if (isset($entity->is_album) && !$entity->is_album)
continue;
$size = $storage->get_image_dimensions($entity, $size_name);
$thumb_size = $storage->get_image_dimensions($entity, $thumbnail_size_name);
$parts = M_NextGen_PictureFill::prepare_picture_element($entity, $size_name);
$full_parts = M_NextGen_PictureFill::prepare_picture_element($entity, 'full');
$retval[] = array(
'image' => $storage->get_image_url($entity, $size_name),
'srcsets' => $parts['srcsets_unfiltered'],
'use_hdpi' => $parts['use_hdpi'],
'title' => $entity->alttext,
'description' => $entity->description,
'image_id' => $entity->{$entity->id_field},
'thumb' => $storage->get_image_url($entity, $thumbnail_size_name),
'width' => $size['width'],
'height' => $size['height'],
'full_image' => $storage->get_image_url($entity, 'full'),
'full_use_hdpi' => $full_parts['use_hdpi'],
'full_srcsets' => $full_parts['srcsets_unfiltered'],
'thumb_dimensions' => array(
'width' => $thumb_size['width'],
'height' => $thumb_size['height']
)
);
$dyn_params = array(
'width' => $ds['thumbnail_width'],
'height' => $ds['thumbnail_height'],
'crop' => true
);
$thumbnail_size_name = $dynthumbs->get_size_name($dyn_params);
}
if (!empty($ds['override_image_settings'])
&& $ds['override_image_settings']
&& !empty($ds['override_image_size_name']))
$size_name = $ds['override_image_size_name'];
// Localize the gallery images for startup performance
$llm->_add_script_data(
'ngg_common',
'galleries.gallery_' . $displayed_gallery->id() . '.images_list',
apply_filters(
'ngg_pro_lightbox_images_queue',
self::format_entities(
$displayed_gallery->get_entities($limit),
$size_name,
$thumbnail_size_name
)
),
FALSE
);
$llm->_add_script_data(
'ngg_common',
'galleries.gallery_' . $displayed_gallery->id() . '.images_list_limit',
$limit,
FALSE
);
$llm->_add_script_data(
'ngg_common',
'galleries.gallery_' . $displayed_gallery->id() . '.images_list_count',
$displayed_gallery->get_entity_count(),
FALSE
<?php
/**
* Class A_Galleria_Controller
* @mixin C_Display_Type_Controller
* @adapts I_Display_Type_Controller using "photocrati-galleria" context
*/
class A_Galleria_Controller extends Mixin
{
function enqueue_frontend_resources($displayed_gallery)
{
// Add some properties to the displayed gallery
$this->object->_compute_aspect_ratio($displayed_gallery);
// Include ngg_common.js
$this->call_parent('enqueue_frontend_resources', $displayed_gallery);
M_Galleria::enqueue_entities($displayed_gallery);
wp_enqueue_script('ngg_galleria');
wp_enqueue_script('ngg_galleria_init', $this->get_static_url(NGG_PRO_GALLERIA . '#ngg_galleria.js'), array('ngg_galleria'), '1.0');
$this->enqueue_ngg_styles();
}
function _compute_aspect_ratio($displayed_gallery, $type = null)
{
$storage = C_Gallery_Storage::get_instance();
$list = $displayed_gallery->get_included_entities();
if ($type == null) {
$type = !empty($displayed_gallery->display_settings['aspect_ratio']) ? $displayed_gallery->display_settings['aspect_ratio'] : 'image_average';
}
switch ($type) {
case 'first_image':
if ($list != null) {
$image = $list[0];
$dims = $storage->get_image_dimensions($image);
$ratio = round($dims['width'] / $dims['height'], 2);
$displayed_gallery->display_settings['aspect_ratio_computed'] = $ratio;
}
break;
case 'image_average':
if ($list != null) {
$ratio_sum = 0;
$image_count = 0;
foreach ($list as $image) {
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}");
}
<?php
class A_NextGen_Pro_Slideshow extends Mixin
{
}
// TODO: This should be replaced by a dynamic stylesheet adapter
/**
* Class A_NextGen_Pro_Slideshow_Controller
* @mixin C_Display_Type_Controller
* @mixin I_Display_Type_Controller using "photocrati-nextgen_pro_slideshow" context
*/
class A_NextGen_Pro_Slideshow_Controller extends A_Galleria_Controller
{
function enqueue_frontend_resources($displayed_gallery)
{
$router = C_Router::get_instance();
$displayed_gallery->display_settings['theme'] = 'nextgen_pro_slideshow';
wp_enqueue_script('ngg_pro_slideshow_theme_js', $router->get_static_url(NGG_PRO_SLIDESHOW . '#theme/galleria.nextgen_pro_slideshow.js'), array('ngg_galleria_init'), '2.0');
wp_enqueue_style('ngg_pro_slideshow_theme_css', $router->get_static_url(NGG_PRO_SLIDESHOW . '#theme/galleria.nextgen_pro_slideshow.css'), array(), '2.0');
return C_Display_Type_Controller::get_instance(NGG_PRO_GALLERIA)->enqueue_frontend_resources($displayed_gallery);
}
}
/**
* Class A_NextGen_Pro_Slideshow_Form
* @mixin C_Form
* @adapts I_Form using "photocrati-nextgen_pro_slideshow" context
*/
class A_NextGen_Pro_Slideshow_Form extends Mixin_Display_Type_Form
{
function get_display_type_name()
{
return NGG_PRO_SLIDESHOW;
}
function enqueue_static_resources()
{
wp_enqueue_script($this->get_display_type_name() . '-js', $this->get_static_url('photocrati-nextgen_pro_slideshow#settings.js'));
$atp = C_Attach_Controller::get_instance();
if ($atp != null && $atp->has_method('mark_script')) {
$atp->mark_script($this->object->get_display_type_name() . '-js');
}
}
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}");
}
// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
} elseif ( in_array( $displayed_gallery->source, [ 'random', 'random_images' ] ) ) {
$lookup = false;
} elseif ( $app->get_parameter( 'show' ) ) {
$lookup = false;
} elseif ( $controller->is_cachable() === false ) {
$lookup = false;
} elseif ( ! NGG_RENDERING_CACHE_ENABLED ) {
$lookup = false;
}
// Just in case M_Gallery_Display could not find this displayed gallery during wp_enqueue_scripts (most likely
// because this displayed gallery was created through do_shortcode) we'll enqueue it now. This may potentially
// cause issues with displays adding their JS or CSS after the <body> has began or finished.
if ( ( ! defined( 'NGG_SKIP_LOAD_SCRIPTS' ) || ! NGG_SKIP_LOAD_SCRIPTS )
&& ! $this->is_rest_request()
// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
&& ! in_array( $displayed_gallery->id(), DisplayManager::$enqueued_displayed_gallery_ids ) ) {
DisplayManager::$enqueued_displayed_gallery_ids[] = $displayed_gallery->id();
$controller->enqueue_frontend_resources( $displayed_gallery );
}
// Try cache lookup, if we're to do so.
$key = null;
$html = false;
if ( $lookup ) {
// The display type may need to output some things even when serving from the cache.
if ( method_exists( $controller, 'cache_action' ) ) {
$retval = $controller->cache_action( $displayed_gallery );
}
if ( method_exists( $controller, 'index_action' ) ) {
if ( ( isset( $displayed_gallery->source ) && 'albums' === $displayed_gallery->source ) &&
( isset( $displayed_gallery->display_type ) && 'imagely-pro-search' !== $displayed_gallery->display_type ) ) {
$controller->index_action( $displayed_gallery, true );
}
}
// Output debug message.
$retval .= $this->debug_msg( 'Lookup!' );
* @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;
* "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;
}
/**
* @return string
*/
public function paged_content() {
global $page;
return $this->content($page, -1);
}
/**
* Get the date to use in your template!
* @api
* @example
* ```twig
* Published on {{ post.date }} // Uses WP's formatting set in Admin
* OR
* Published on {{ post.date('F jS') }} // Jan 12th
* ```
*
* ```html
* Published on January 12, 2015
* OR
* Published on Jan 12th
* ```
* @param string $date_format
* @return string
*/
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), "paged_content", []);
echo "
";
// line 49
echo call_user_func_array($this->env->getFunction('function')->getCallable(), ["wp_link_pages", ["before" => "<div class=\"page-links\" itemprop=\"pagination\"><ul class=\"pagination-list\">", "after" => "</ul></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 79
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"] = "single.html.twig";
// line 3
$context["scope"] = "single";
// line 1
$this->parent = $this->loadTemplate("partials/page.html.twig", "single.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"], "single.html.twig", 11)->display($context);
// line 12
echo "
</section>
</div> <!-- /content-wrapper -->
</div>
";
}
public function getTemplateName()
{
return "single.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"] = "single.html.twig";
// line 3
$context["scope"] = "single";
// line 1
$this->parent = $this->loadTemplate("partials/page.html.twig", "single.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"], "single.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
*/
*/
defined('ABSPATH') or die;
/*
* The Template for displaying all single posts
*/
$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;
$context['wp_title'] .= ' - ' . $post->title();
Timber::render(['single-' . $post->ID . '.html.twig', 'single-' . $post->post_type . '.html.twig', 'single.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';