/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/Core.php
}
/**
* Takes an array or object and adds the properties to the parent object
* @example
* ```php
* $data = array('airplane' => '757-200', 'flight' => '5316');
* $post = new Timber\Post()
* $post->import(data);
* echo $post->airplane; //757-200
* ```
* @param array|object $info an object or array you want to grab data from to attach to the Timber object
*/
public function import( $info, $force = false ) {
if ( is_object($info) ) {
$info = get_object_vars($info);
}
if ( is_array($info) ) {
foreach ( $info as $key => $value ) {
if ( $key === '' || ord($key[0]) === 0 ) {
continue;
}
if ( !empty($key) && $force ) {
$this->$key = $value;
} else if ( !empty($key) && !method_exists($this, $key) ) {
$this->$key = $value;
}
}
}
}
/**
* @ignore
* @param string $key
* @param mixed $value
*/
public function update( $key, $value ) {
update_metadata($this->object_type, $this->ID, $key, $value);
}
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/Core.php
}
/**
* Takes an array or object and adds the properties to the parent object
* @example
* ```php
* $data = array('airplane' => '757-200', 'flight' => '5316');
* $post = new Timber\Post()
* $post->import(data);
* echo $post->airplane; //757-200
* ```
* @param array|object $info an object or array you want to grab data from to attach to the Timber object
*/
public function import( $info, $force = false ) {
if ( is_object($info) ) {
$info = get_object_vars($info);
}
if ( is_array($info) ) {
foreach ( $info as $key => $value ) {
if ( $key === '' || ord($key[0]) === 0 ) {
continue;
}
if ( !empty($key) && $force ) {
$this->$key = $value;
} else if ( !empty($key) && !method_exists($this, $key) ) {
$this->$key = $value;
}
}
}
}
/**
* @ignore
* @param string $key
* @param mixed $value
*/
public function update( $key, $value ) {
update_metadata($this->object_type, $this->ID, $key, $value);
}
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/Post.php
return $revision->ID;
}
return false;
}
/**
* Initializes a Post
* @internal
* @param integer $pid
*/
protected function init( $pid = false ) {
if ( $pid === false ) {
$pid = get_the_ID();
}
if ( is_numeric($pid) ) {
$this->ID = $pid;
}
$post_info = $this->get_info($pid);
$this->import($post_info);
}
/**
* Get the URL that will edit the current post/object
* @internal
* @deprecated since 1.0
* @codeCoverageIgnore
* @see Timber\Post::edit_link
* @return bool|string
*/
public function get_edit_url() {
return $this->edit_link();
}
/**
* updates the post_meta of the current object with the given value
* @param string $field
* @param mixed $value
*/
public function update( $field, $value ) {
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/Post.php
*/
public $slug;
/**
* @var PostType $_type stores the PostType object for the Post
*/
protected $__type;
/**
* If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
* @example
* ```php
* $post = new Timber\Post();
* $other_post = new Timber\Post($random_post_id);
* ```
* @param mixed $pid
*/
public function __construct( $pid = null ) {
$pid = $this->determine_id($pid);
$this->init($pid);
}
/**
* This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
* This is also here to ensure that {{ post.class }} remains usable
* @return mixed
*/
public function __get( $field ) {
if ( 'class' === $field ) {
return $this->css_class();
}
return parent::__get($field);
}
/**
* This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
* This is also here to ensure that {{ post.class }} remains usable
* @return mixed
*/
public function __call( $field, $args ) {
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/PostCollection.php
*/
$posts_iterator = apply_filters('timber/class/posts_iterator', $posts_iterator, $returned_posts, $post_class);
parent::__construct($returned_posts, 0, $posts_iterator);
}
protected static function init( $posts, $post_class ) {
$returned_posts = array();
if ( is_null($posts) ) {
$posts = array();
}
foreach ( $posts as $post_object ) {
$post_type = get_post_type($post_object);
$post_class_use = PostGetter::get_post_class($post_type, $post_class);
// Don't create yet another object if $post_object is already of the right type
if ( is_a($post_object, $post_class_use) ) {
$post = $post_object;
} else {
$post = new $post_class_use($post_object);
}
if ( isset($post->ID) ) {
$returned_posts[] = $post;
}
}
return self::maybe_set_preview($returned_posts);
}
public function get_posts() {
return $this->getArrayCopy();
}
/**
* @param array $posts
* @return array
*/
public static function maybe_set_preview( $posts ) {
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/PostCollection.php
<?php
namespace Timber;
use Timber\Helper;
use Timber\Post;
/**
* Class PostCollection
*
* PostCollections are internal objects used to hold a collection of posts.
*
* @package Timber
*/
class PostCollection extends \ArrayObject {
public function __construct( $posts = array(), $post_class = '\Timber\Post' ) {
$returned_posts = self::init($posts, $post_class);
$posts_iterator = 'Timber\PostsIterator';
/**
* Filters the PostIterator class to use for a PostCollection.
*
* This filter is useful if you need to set special values or globals on each post. Because many plugins still
* rely on The Loop, a custom PostIterator can make it much easier to integrate third party plugins with Timber.
*
* @since 1.4.x
*
* @param string $posts_iterator The iterator class to use to loop over posts. Default `Timber\PostsIterator`.
* @param array $returned_posts An array of posts.
* @param string $post_class The post class to use to extend posts with.
*/
$posts_iterator = apply_filters('timber/class/posts_iterator', $posts_iterator, $returned_posts, $post_class);
parent::__construct($returned_posts, 0, $posts_iterator);
}
protected static function init( $posts, $post_class ) {
$returned_posts = array();
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/QueryIterator.php
/**
* Gets the amount of found posts in the query.
*
* @api
* @since 1.11.1
*
* @return int
*/
public function found_posts() {
return $this->_query->found_posts;
}
public function get_pagination( $prefs ) {
return new Pagination($prefs, $this->_query);
}
public function get_posts( $return_collection = false ) {
if ( isset($this->_query->posts) ) {
$posts = new PostCollection($this->_query->posts, $this->_posts_class);
return ($return_collection) ? $posts : $posts->get_posts();
}
}
//
// GET POSTS
//
public static function get_query_from_array_of_ids( $query = array() ) {
if ( !is_array($query) || !count($query) ) {
return null;
}
return new \WP_Query(array(
'post_type'=> 'any',
'ignore_sticky_posts' => true,
'post__in' => $query,
'orderby' => 'post__in',
'nopaging' => true
));
}
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/PostQuery.php
*/
public $found_posts = null;
protected $userQuery;
protected $queryIterator;
protected $pagination = null;
/**
* @param mixed $query
* @param string $post_class
*/
public function __construct( $query = false, $post_class = '\Timber\Post' ) {
$this->userQuery = $query;
$this->queryIterator = PostGetter::query_posts($query, $post_class);
if ( $this->queryIterator instanceof QueryIterator ) {
$this->found_posts = $this->queryIterator->found_posts();
}
$posts = $this->queryIterator->get_posts();
parent::__construct($posts, $post_class);
}
/**
* @return mixed the query the user orignally passed
* to the pagination object
*/
protected function get_query() {
return $this->userQuery;
}
/**
* Set pagination for the collection. Optionally could be used to get pagination with custom preferences.
*
* @param array $prefs
* @return Timber\Pagination object
*/
public function pagination( $prefs = array() ) {
if ( !$this->pagination && is_a($this->queryIterator, 'Timber\QueryIterator') ) {
/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/Timber.php
}
/**
* Get context.
* @api
* @return array
*/
public static function get_context() {
if ( empty(self::$context_cache) ) {
self::$context_cache['http_host'] = URLHelper::get_scheme().'://'.URLHelper::get_host();
self::$context_cache['wp_title'] = Helper::get_wp_title();
self::$context_cache['body_class'] = implode(' ', get_body_class());
self::$context_cache['site'] = new Site();
self::$context_cache['request'] = new Request();
$user = new User();
self::$context_cache['user'] = ($user->ID) ? $user : false;
self::$context_cache['theme'] = self::$context_cache['site']->theme;
self::$context_cache['posts'] = new PostQuery();
/**
* @deprecated as of Timber 1.3.0
* @todo remove in Timber 1.4.*
*/
self::$context_cache['wp_head'] = new FunctionWrapper( 'wp_head' );
self::$context_cache['wp_footer'] = new FunctionWrapper( 'wp_footer' );
self::$context_cache = apply_filters('timber_context', self::$context_cache);
self::$context_cache = apply_filters('timber/context', self::$context_cache);
}
return self::$context_cache;
}
/**
* Compile a Twig file.
*
* Passes data to a Twig file and returns the output.
/data/websites/webnews/web/app/themes/webnews/src/ViewModel/Base.php
*
* expose getData()
*
* and ask to implement setPageData();
*
*/
abstract class Base {
protected $data; // the data to be sent to the views
protected $context;
protected $paged;
/**
* Base constructor
*/
function __construct() {
global $paged;
// take the context from Timber
$this->context = Timber::get_context();
$this->paged = $paged;
// init the data array
$this->setPageData();
$this->setHeadAndFooterCore();
// basic components
$this->setMenu();
$this->setIsMobile();
$this->setDomain();
$this->setGTM_ID();
//$this->setSidebarsData();
//$this->setTaxonomiesData();
//$this->setAdvData();
//$this->setFooterData();
/data/websites/webnews/web/app/themes/webnews/src/ViewModel/Single.php
<?php
namespace THEME\ViewModel;
// NOTA PER REFACTORING: fare una funzione che elechi solo i
/**
* Set data common to all the single contents
*/
class Single extends Base {
protected $post;
protected $postTemplate;
protected $components;
function __construct($post, $postTemplate = 'Single') {
parent::__construct();
$this->post = $post;
// assign the post template (default is 'Single')
$this->postTemplate = $this->postTemplateFactory($postTemplate);
// init the post template
// (includes content details as well)
$this->setPost();
// set the components list into property
// $components
$this->initComponents();
// add all the default components
$this->setComponents();
}
/**
/data/websites/webnews/web/app/themes/webnews/single.php
<?php
use Timber\Timber;
use THEME\ViewModel\Single;
use THEME\ViewModel\SingleMaxReina;
if (have_posts()) {
$ajax = ( isset( $_GET['is_ajax_request']) );
/// ottimizzazione per autore secondario di MaxReina
$secondaryMaxReinaUser = get_user_by('login', WN_SECONDARY_USER_FOR_MAXREINA);
$singleClass = $posts[0]->post_author == $secondaryMaxReinaUser->ID ? SingleMaxReina::class : Single::class;
// load data
$data = ( new $singleClass( $posts[0], 'SingleSplittedContent') )->getData();
$template = $ajax ? 'singleAjax.twig' : 'single-notizia.twig';
Timber::render( $template, $data);
}
?>
/data/websites/webnews/web/wp/wp-includes/template-loader.php
}
break;
}
}
if ( ! $template ) {
$template = get_index_template();
}
/**
* Filters the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
$template = apply_filters( 'template_include', $template );
if ( $template ) {
include $template;
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
}
/data/websites/webnews/web/wp/wp-blog-header.php
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}
/data/websites/webnews/web/index.php
<?php
/**
* WordPress View Bootstrapper
*/
define('WP_USE_THEMES', true);
require __DIR__ . '/wp/wp-blog-header.php';