</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
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
$current_url = $this->object->get_routed_url(TRUE);
$storage = C_Gallery_Storage::get_instance();
$mapper = C_Image_Mapper::get_instance();
$entities = $displayed_gallery->get_included_entities();
foreach ($entities as &$entity) {
$entity->entity_type = $entity_type = intval($entity->is_gallery) ? 'gallery' : 'album';
// Is the gallery actually a link to a page? Stupid feature...
if (isset($entity->pageid) && $entity->pageid > 0) {
$entity->link = get_page_link($entity->pageid);
} else {
$page_url = $current_url;
if (intval($entity->is_gallery) && !$this->param('album')) {
$page_url = $this->object->set_param_for($page_url, 'album', 'galleries');
}
$entity->link = $this->object->set_param_for($page_url, $entity_type, $entity->slug);
}
// Add image information to the gallery object
$entity->previewpic_image = $preview_img = $mapper->find($entity->previewpic);
$entity->thumb_size = $storage->get_image_dimensions($preview_img, $thumbnail_size_name);
$entity->previewpic_image_url = $storage->get_image_url($preview_img, 'full');
$entity->previewpic_thumbnail_url = $entity->previewpic_thumb_url = $storage->get_image_url($preview_img, $thumbnail_size_name, TRUE);
// If the setting is on we need to inject an effect code
if (!empty($displayed_gallery->display_settings['open_gallery_in_lightbox']) && $entity_type == 'gallery') {
$entity = $this->object->make_child_displayed_gallery($entity, $displayed_gallery->display_settings);
if ($this->does_lightbox_support_displayed_gallery($displayed_gallery)) {
$entity->displayed_gallery->effect_code = $this->object->get_effect_code($entity->displayed_gallery);
}
}
}
$entities = apply_filters('ngg_pro_album_prepared_child_entity', $entities, $displayed_gallery);
return $entities;
}
/**
* Creates a displayed gallery of a gallery belonging to an album. Shared by index_action() and cache_action() to
* allow lightboxes to open album children directly.
*
* @param object $gallery
* @param array $display_settings
* @return C_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}");
}
if ($displayed_gallery->display_settings['thumbnail_quality']) {
$dyn_params['quality'] = $displayed_gallery->display_settings['thumbnail_quality'];
}
if ($displayed_gallery->display_settings['thumbnail_crop']) {
$dyn_params['crop'] = true;
}
if ($displayed_gallery->display_settings['thumbnail_watermark']) {
$dyn_params['watermark'] = true;
}
$thumbnail_size_name = $dynthumbs->get_size_name($dyn_params);
}
return $thumbnail_size_name;
}
function _render_album($displayed_gallery, $original_entities, $return)
{
// The HTML id of the gallery
$id = 'displayed_gallery_' . $displayed_gallery->id();
$thumbnail_size_name = $this->object->_get_displayed_gallery_thumbnail_size_name($displayed_gallery);
// Get entities
$entities = $this->object->_prepare_entities($displayed_gallery, $thumbnail_size_name);
// Render view/template
$params = array_merge($displayed_gallery->display_settings, array('entities' => $entities, 'effect_code' => $this->object->get_effect_code($displayed_gallery), 'id' => $id, 'thumbnail_size_name' => $thumbnail_size_name, 'css_class' => $this->object->_get_css_class()));
$params = $this->object->prepare_display_parameters($displayed_gallery, $params);
if (!is_null($original_entities)) {
$displayed_gallery->display_settings['original_album_id'] = 'a' . $displayed_gallery->container_ids[0];
$displayed_gallery->display_settings['original_album_entities'] = $original_entities;
}
return $this->render_partial('photocrati-nextgen_pro_albums#index', $params, $return);
}
function _prepare_entities($displayed_gallery, $thumbnail_size_name)
{
$current_url = $this->object->get_routed_url(TRUE);
$storage = C_Gallery_Storage::get_instance();
$mapper = C_Image_Mapper::get_instance();
$entities = $displayed_gallery->get_included_entities();
foreach ($entities as &$entity) {
$entity->entity_type = $entity_type = intval($entity->is_gallery) ? 'gallery' : 'album';
// Is the gallery actually a link to a page? Stupid feature...
if (isset($entity->pageid) && $entity->pageid > 0) {
$entity->link = get_page_link($entity->pageid);
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}");
}
$displayed_gallery->display_settings['open_gallery_in_lightbox'] = 0;
}
$retval = '';
// Determine what to render:
// 1) A gallery
if ($this->param('gallery')) {
$retval = $this->object->_render_gallery($displayed_gallery->display_settings['gallery_display_type'], $displayed_gallery->display_type, $displayed_gallery->display_settings, $displayed_gallery->get_albums(), TRUE);
} else {
if ($album_id = $this->param('album')) {
if (!is_numeric($album_id)) {
$mapper = C_Album_Mapper::get_instance();
$result = $mapper->select()->where(array("slug = %s", $album_id))->limit(1)->run_query();
$result = array_pop($result);
$album_id = $result->{$result->id_field};
}
$original_entities = $displayed_gallery->get_albums();
$displayed_gallery->container_ids = array($album_id);
$retval = $this->object->_render_album($displayed_gallery, $original_entities, $return);
} else {
$retval = $this->object->_render_album($displayed_gallery, NULL, $return);
}
}
return $retval;
}
function add_breadcrumbs_to_legacy_templates($html, $displayed_gallery)
{
if (version_compare(NGG_PLUGIN_VERSION, '2.0.80') <= 0) {
return $html;
}
$this->object->add_mixin('A_NextGen_Album_Breadcrumbs');
$breadcrumbs = $this->object->render_legacy_template_breadcrumbs($displayed_gallery, $displayed_gallery->display_settings['original_album_entities'], $displayed_gallery->conatiner_ids);
if (!empty($breadcrumbs)) {
$html = $breadcrumbs . $html;
}
return $html;
}
/**
* TODO: Remove after 2.1.50 is well circulated
* @param $displayed_gallery
* @param null $lightbox
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';