/data/websites/htmlit/web/app/plugins/affiliation/src/Rendering/PageLinksData.php
$signatureTable = PostSignatureTable::getInstance();
$domain = $this->pageData['domain'];
$post_type = $this->pageData['post_type'];
$post_id = $this->post != null ? $this->post->ID : '';
$taxonomies = $this->pageData['taxonomies'];
$author_id = $this->pageData['author_id'];
$apiCall = BLZ_API_RENDERING_MANAGER . "page/$domain/$post_type/$post_id/$taxonomies/$author_id";
$transient = $signatureTable->getSignatureId( $apiCall );
$result = json_decode( $this->cachedApi->get( $apiCall, 0, $transient ) );
/// questo controllo dovrebbe andare nel rendering manager
if( !isset( $result->rules->type ) ) {
$result->rules->type = '';
$result->rules->custom = '';
$result->rules->po = '';
}
return $result;
}
protected function getPagePath() {
return get_permalink( $this->post );
}
/**
* ritorna un array chiave-valore con i campi dell'oggetto
*
* @return array
*/
Arguments
"Attempt to modify property "rules" on null"
/data/websites/htmlit/web/app/plugins/affiliation/src/Rendering/PageLinksData.php
public function __construct() {
if( !is_singular() ) return;
$this->post = get_post();
add_filter( 'the_content', [ $this, 'printPageLinkAttributes' ], 900 , 1 );
}
public function get() {
$this->cachedApi = CachedApi::getInstance();
$pageDataObj = new PageData( $this->post );
$this->pageData = $pageDataObj->getParams();
$gtPageData = $this->getGTPageData();
$this->domain = $this->pageData['domain'];
$this->author = $this->post == null ? '' : $gtPageData->author->name;
$this->alias = $this->post == null ? '' : $gtPageData->author->alias_name;
$this->tipologia = $this->post == null ? '' : $gtPageData->rules->type;
$this->custom = $this->post == null ? '' : $gtPageData->rules->custom;
$this->po = $this->post == null || !isset($gtPageData->rules->po) ?'' : $gtPageData->rules->po;
$this->path = $this->post == null ? '' : $this->getPagePath();
$this->postid = $this->post == null ? '' : $this->post->ID;
}
function getGTPageData() {
$signatureTable = PostSignatureTable::getInstance();
$domain = $this->pageData['domain'];
$post_type = $this->pageData['post_type'];
$post_id = $this->post != null ? $this->post->ID : '';
$taxonomies = $this->pageData['taxonomies'];
/data/websites/htmlit/web/app/plugins/affiliation/src/Rendering/PageLinksData.php
public function getPageData( $params ) {
$this->domain = empty( $params['domain'] ) ? $this->domain : $params['domain'];
$this->author = empty( $params['author'] ) ? $this->author : $params['author'];
$this->tipologia = empty( $params['tipologia'] ) ? $this->tipologia : $params['tipologia'];
$this->custom = empty( $params['custom'] ) ? $this->custom : $params['custom'];
$this->po = empty( $params['po' ] ) ? $this->po : $params['po'];
}
/**
* Inserisce i dati raccolti dai link prima del body
*
* @return string
*/
public function printPageLinkAttributes( $content ) {
$this->get();
$data = $this->toArray();
$linksData = LinksDataInPage::getInstance();
$data['programs'] = implode( ',', $linksData->getPrograms() );
$data['subjects'] = implode( ',', $linksData->getSubjects() );
$data['themes' ] = implode( ',', $linksData->getThemes() );
$dataAttributes = $this->toDataAttributes( $data );
$data_element = '<span class="bm_post" style="display:none"'.$dataAttributes.'></span>';
return $content . $data_element;
}
}
/data/websites/htmlit/web/wp/wp-includes/class-wp-hook.php
$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.
/data/websites/htmlit/web/wp/wp-includes/plugin.php
$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`.
/data/websites/htmlit/web/app/themes/htmlit/src/ViewModel/Post/Content/SplittedContent.php
*
* @return Array sections
*/
public function getSections() {
return $this->sections;
}
private function init($content) {
// load all the splitters
$this->getAvailableSplitters();
// cambiare gli shortcode "mutati"
foreach($this->splitters as $splitter)
$content = $splitter->convertShortCode($content);
// applicare gli shortcode "reali"
$content = apply_filters('the_content', $content);
// initialize the content as a big section to split
$this->sections = [
[ 'type' => 'content', 'content' => $content ]
];
foreach ($this->splitters as $splitter)
$this->splitSections($splitter);
}
/**
* Return the list of the splitters
*/
private function getAvailableSplitters(){
// una reflection un po' accroccata ma funzionale
$composer = require get_template_directory() . '/vendor/composer/autoload_classmap.php';
$namespaces = array_keys( $composer );
/data/websites/htmlit/web/app/themes/htmlit/src/ViewModel/Post/Content/SplittedContent.php
* @param content:string - is the content to split
* @param post_id:int - the current post id
*
* getSections() - Array with the sequence of content sections to print
* each one indentified with a type and a content
*
* splitContent() - activate the splitter on a new content
*/
class SplittedContent
{
private $splitters;
private $sections = [];
private $post_id = 0;
function __construct($post)
{
$this->post_id = $post->ID;
$this->init($post->post_content);
}
/**
* Expose the sections
*
* @return Array sections
*/
public function getSections() {
return $this->sections;
}
private function init($content) {
// load all the splitters
$this->getAvailableSplitters();
// cambiare gli shortcode "mutati"
/data/websites/htmlit/web/app/themes/htmlit/src/ViewModel/Post/Templates/SingleSplittedContent.php
*
public function getPostData($post) {
$processedPost = parent::getPostData($post);
$processedPost['content'] = $this->getContent($post);
return $processedPost;
}
*/
/**
* Returns the content as a list (array) of splitted sections
*
* @param WP_Post $post
* @return array
*/
protected function getContent( $post ) {
return ( new SplittedContent( $post ) )->getSections();
}
}
/data/websites/htmlit/web/app/themes/htmlit/src/ViewModel/Post/Templates/Single.php
class Single implements iTemplate {
/**
* Basic post data for a generic Single
*
* @param WP_Post $post
* @return array
*/
public function getPostData( $post ) {
$ratings_average = get_post_meta( $post->ID , 'ratings_average', true );
/// basic post data
$postData = [
'id' => $post->ID,
'title' => $post->post_title,
'excerpt' => $post->post_excerpt,
'content' => $this->getContent( $post ),
'image' => $this->getImage( $post ),
'pubdate' => $this->getDate("post_date", $post ),
'moddate' => $this->getDate("post_modified", $post ),
'tags' => $this->getTags( $post ),
'link' => get_the_permalink( $post ),
'ratings_average' => $ratings_average,
];
/// add post_meta to basic data
$customFields = $this->getCustomFields( $post );
if( is_array( $customFields ) && !empty( $customFields ) ) {
$postData = array_merge( $postData, $customFields );
}
return $postData;
}
/data/websites/htmlit/web/app/themes/htmlit/src/ViewModel/Single.php
/**
* Writes the basic page info
*/
protected function setPageData(){
$this->data = [
'type' => 'single_post',
'area' => 'learn',
'infinite' => 'true'
];
}
/**
* Add the post info to data
*/
protected function setPost() {
$this->data['post'] = $this->postTemplate->getPostData($this->post);
}
/**
* set the list of the components
* override this to add or remove components
*/
protected function initComponents() {
$this->components = [
'Author',
'Taxonomies',
'Adv',
'BreadcrumbsPrimary',
'Relateds',
'StructuredData',
'Credits',
'Newsletter',
'Canonical',
'Meta'
];
/data/websites/htmlit/web/app/themes/htmlit/src/ViewModel/Single.php
*/
class Single extends BaseHtmlIt {
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();
}
/**
* Writes the basic page info
*/
protected function setPageData(){
$this->data = [
'type' => 'single_post',
'area' => 'learn',
'infinite' => 'true'
/data/websites/htmlit/web/app/themes/htmlit/src/ViewModel/SingleNews.php
<?php
namespace HTML\ViewModel;
use HTML\ViewModel\Single;
/**
* Set data common to all the single contents
*/
class SingleNews extends Single {
protected $infinite = true;
function __construct( $post, $postTemplate = 'Single') {
$this->infinite = !has_tag('no-infinite', $post );
parent::__construct( $post, $postTemplate );
}
/**
* Writes the basic page info
*/
protected function setPageData(){
$this->data = [
'type' => 'single_news',
'area' => 'magazine',
'infinite' => $this->infinite ? 'true' : 'false'
];
}
/**
* set the list of the components
* override this to add or remove components
*/
protected function initComponents() {
$this->components = [
/data/websites/htmlit/web/app/themes/htmlit/single-news.php
<?php
use HTML\ViewModel\SingleNews;
use Timber\Timber;
$is_ajax = ( isset( $_GET['is_ajax_request']) );
$single = ( new SingleNews($post , 'SingleSplittedContent') )->getData();
$template = $is_ajax ? 'singleAjax.twig' : 'single-notizia.twig';
Timber::render( $template, $single );
/data/websites/htmlit/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;
}
Arguments
"/data/websites/htmlit/web/app/themes/htmlit/single-news.php"
/data/websites/htmlit/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';
}
Arguments
"/data/websites/htmlit/web/wp/wp-includes/template-loader.php"
/data/websites/htmlit/web/index.php
<?php
/** WordPress view bootstrapper */
define('WP_USE_THEMES', true);
require __DIR__ . '/wp/wp-blog-header.php';
Arguments
"/data/websites/htmlit/web/wp/wp-blog-header.php"