/data/websites/webnews/web/app/themes/webnews/vendor/timber/timber/lib/Core.php
}
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;
}
}
}
}
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/Archive.php
*/
class Archive extends Base {
const ARCHIVE_POSTS_PER_PAGE = 30; //
protected $term;
protected $tot_pages;
protected $postTemplate;
function __construct( $postTemplate = 'Archive', $archiveTemplate = 'Archive' ) {
$queried_object = get_queried_object();
$obj_type = empty( $queried_object ) ? '' : get_class( $queried_object ) ;
$this->term = ( $obj_type == 'WP_Term' ) ? $queried_object : null;
$this->post_type = ( $obj_type == 'WP_Post_Type' ) ? $queried_object : null;
$this->author = ( $obj_type == 'WP_User' ) ? $queried_object : null;
parent::__construct();
// set the postTemplate (default 'Archive')
$this->postTemplate = $this->postTemplateFactory( $postTemplate );
// set the archiveTemplate (default 'Archive')
$this->archiveTemplate = $this->archiveTemplateFactory( $archiveTemplate );
// add the current term's data
$this->setTerm( $obj_type );
// add the articles to data
$this->setArticles();
// set the components list into property
// $components
$this->initComponents();
// add all the default components
$this->setComponents();
}
/data/websites/webnews/web/app/themes/webnews/src/ViewModel/Author.php
<?php
namespace THEME\ViewModel;
class Author extends Archive {
/// inutile se non si aggiunge nulla ma probabile ch de
function __construct( $postTemplate = 'Archive', $archiveTemplate = 'Author') {
parent::__construct( $postTemplate, $archiveTemplate );
}
/**
* set the posts list as articles array using
* the standard wp_query
*
* AND SET the total pages to data ( lo so qui bisognerebbe architettarlo un mo meglio)
*
* @return void
*/
protected function setArticles() {
// create the query for main contents
$archive_args = [
'posts_per_page' => Archive::ARCHIVE_POSTS_PER_PAGE,
'paged' => $this->paged,
'post_status' => 'publish',
'post_type' => 'post',
'author__in' => $this->getAuthorIds()
];
// create the query for main contents
$archive_query = new \WP_Query( $archive_args );
$archive_articles = $archive_query->posts ;
$tot_pages = $archive_query->max_num_pages;
// create data.articles
// as an array of posts
/data/websites/webnews/web/app/themes/webnews/author.php
<?php
use Env\Env;
use THEME\ViewModel\Author;
use THEME\ViewModel\AuthorMaxReina;
use THEME\ViewModel\Page404;
use Timber\Timber;
$paged = ( get_query_var('paged') && get_query_var('paged') !== 0 ) ? get_query_var('paged') : 1;
if( is_bool( get_queried_object() ) ) {
$data = ( new Page404 )->getData();
$template = 'page-404.twig';
} else {
$author = get_query_var('author') == 49788 ? new AuthorMaxReina(WN_SECONDARY_USER_FOR_MAXREINA) : new Author;
$data = $author->getData();
$data['page'] = $paged;
$template = ( $paged == 1 ) ? 'archive-author.twig' : 'archive-author-paged.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';