/data/websites/telefonino/web/app/themes/telefonino/src/ViewModel/Post/Templates/RSS.php
namespace THEME\ViewModel\Post\Templates;
/**
* Pay attention this is the representation
* of a POST into an Archive contex\t
*
*/
class RSS extends Archive implements iTemplate {
function __construct() {
remove_all_filters( 'wp_get_attachment_image_src', 1);
}
public function getPostData( $post ) {
$postimages = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'blz_large');
$headers = empty( $postimages ) ? [] : array_change_key_case( get_headers( $postimages[0], true ) );
$image = empty( $postimages ) ? [] : (object) [
'url' => str_replace("https", "http", esc_url( $postimages[0] )),
'length' => isset( $headers['content-length'] ) ? $headers['content-length'] : ''
];
$post_categories = wp_get_post_terms( $post->ID, 'category' );
$categories = array_reduce( $post_categories, function( $xml, $cat ) {
return $xml .= '<category><![CDATA['.$cat->name.']]></category>';
}, '');
return [
'id' => $post->ID,
'title' => $post->post_title,
'permalink' => get_the_permalink( $post->ID ),
'pubdate' => mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true, $post ), false ),
'image' => empty( $image ) ? [] : [
'url' => $image->url,
/data/websites/telefonino/web/app/themes/telefonino/src/ViewModel/Post/Templates/RSS.php
namespace THEME\ViewModel\Post\Templates;
/**
* Pay attention this is the representation
* of a POST into an Archive contex\t
*
*/
class RSS extends Archive implements iTemplate {
function __construct() {
remove_all_filters( 'wp_get_attachment_image_src', 1);
}
public function getPostData( $post ) {
$postimages = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'blz_large');
$headers = empty( $postimages ) ? [] : array_change_key_case( get_headers( $postimages[0], true ) );
$image = empty( $postimages ) ? [] : (object) [
'url' => str_replace("https", "http", esc_url( $postimages[0] )),
'length' => isset( $headers['content-length'] ) ? $headers['content-length'] : ''
];
$post_categories = wp_get_post_terms( $post->ID, 'category' );
$categories = array_reduce( $post_categories, function( $xml, $cat ) {
return $xml .= '<category><![CDATA['.$cat->name.']]></category>';
}, '');
return [
'id' => $post->ID,
'title' => $post->post_title,
'permalink' => get_the_permalink( $post->ID ),
'pubdate' => mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true, $post ), false ),
'image' => empty( $image ) ? [] : [
'url' => $image->url,
/data/websites/telefonino/web/app/themes/telefonino/src/ViewModel/InoReaderRss.php
'orderby' => 'date',
'order' => 'DESC',
'post_status' => 'publish',
'posts_per_page' => $this->postCount,
'date_query' => [
[
'year' => date('Y'),
'month' => date('n'),
'day' => date('j'),
],
]
];
// create the query for main contents
$posts = get_posts( $args_base );
$this->data['articles'] = array_map( function ( $post ) {
// structured as described by the current template
return $this->postTemplate->getPostData( $post );
}, $posts );
}
}
/data/websites/telefonino/web/app/themes/telefonino/src/ViewModel/InoReaderRss.php
$args_base = [
'post_type' => $this->post_type,
'orderby' => 'date',
'order' => 'DESC',
'post_status' => 'publish',
'posts_per_page' => $this->postCount,
'date_query' => [
[
'year' => date('Y'),
'month' => date('n'),
'day' => date('j'),
],
]
];
// create the query for main contents
$posts = get_posts( $args_base );
$this->data['articles'] = array_map( function ( $post ) {
// structured as described by the current template
return $this->postTemplate->getPostData( $post );
}, $posts );
}
}
/data/websites/telefonino/web/app/themes/telefonino/src/ViewModel/CustomRss.php
protected $headerTemplate;
protected $itemTemplate;
function __construct( $category = '', $post_type = '' ) {
$this->category = $category;
$this->post_type = $post_type;
$this->postTemplate = new RSSTemplate;
$this->tagsToExclude = $this->getExcludedTagIds();
$this->headerTemplate = $this->setHeaderTemplate();
$this->itemTemplate = $this->setItemTemplate();
}
public function render() {
$this->setArticles();
$items = array_reduce( $this->data[ 'articles' ], function( $xml, $post ) {
return $xml . $this->fillItem( (object) $post );
}, '');
$rssTemplate = $this->fillHeader( $this->headerTemplate ) ;
$rss = str_replace( '{{ items }}', $items, trim( $rssTemplate ) );
echo $rss;
}
/**
* 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)
/data/websites/telefonino/web/app/themes/telefonino/rss-inoreader.php
<?php
use THEME\ViewModel\InoReaderRss as CustomRss;
$category = isset( $_GET["category"] ) ? strtolower( $_GET["category"] ) : '';
$post_type = isset( $_GET["type"] ) ? strtolower( $_GET["type"] ) : '';
// load data
$rss = ( new CustomRss( $category, $post_type ) );
header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true);
$rss->render();
/data/websites/telefonino/web/wp/wp-includes/template.php
if ( isset( $s ) ) {
$s = esc_attr( $s );
}
/**
* Fires before a template file is loaded.
*
* @since 6.1.0
*
* @param string $_template_file The full path to the template file.
* @param bool $load_once Whether to require_once or require.
* @param array $args Additional arguments passed to the template.
*/
do_action( 'wp_before_load_template', $_template_file, $load_once, $args );
if ( $load_once ) {
require_once $_template_file;
} else {
require $_template_file;
}
/**
* Fires after a template file is loaded.
*
* @since 6.1.0
*
* @param string $_template_file The full path to the template file.
* @param bool $load_once Whether to require_once or require.
* @param array $args Additional arguments passed to the template.
*/
do_action( 'wp_after_load_template', $_template_file, $load_once, $args );
}
/**
* Checks whether the template should be output buffered for enhancement.
*
* By default, an output buffer is only started if a {@see 'wp_template_enhancement_output_buffer'} filter has been
* added by the time a template is included at the {@see 'wp_before_include_template'} action. This allows template
* responses to be streamed as much as possible when no template enhancements are registered to apply.
/data/websites/telefonino/web/wp/wp-includes/template.php
$located = '';
foreach ( (array) $template_names as $template_name ) {
if ( ! $template_name ) {
continue;
}
if ( file_exists( $wp_stylesheet_path . '/' . $template_name ) ) {
$located = $wp_stylesheet_path . '/' . $template_name;
break;
} elseif ( $is_child_theme && file_exists( $wp_template_path . '/' . $template_name ) ) {
$located = $wp_template_path . '/' . $template_name;
break;
} elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
$located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
break;
}
}
if ( $load && '' !== $located ) {
load_template( $located, $load_once, $args );
}
return $located;
}
/**
* Requires the template file with WordPress environment.
*
* The globals are set up for the template file to ensure that the WordPress
* environment is available from within the function. The query variables are
* also available.
*
* @since 1.5.0
* @since 5.5.0 The `$args` parameter was added.
*
* @global array $posts
* @global WP_Post $post Global post object.
* @global bool $wp_did_header
* @global WP_Query $wp_query WordPress Query object.
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
/data/websites/telefonino/web/wp/wp-includes/general-template.php
$templates[] = "{$slug}-{$name}.php";
}
$templates[] = "{$slug}.php";
/**
* Fires before an attempt is made to locate and load a template part.
*
* @since 5.2.0
* @since 5.5.0 The `$args` parameter was added.
*
* @param string $slug The slug name for the generic template.
* @param string $name The name of the specialized template
* or an empty string if there is none.
* @param string[] $templates Array of template files to search for, in order.
* @param array $args Additional arguments passed to the template.
*/
do_action( 'get_template_part', $slug, $name, $templates, $args );
if ( ! locate_template( $templates, true, false, $args ) ) {
return false;
}
}
/**
* Displays search form.
*
* Will first attempt to locate the searchform.php file in either the child or
* the parent, then load it. If it doesn't exist, then the default search form
* will be displayed. The default search form is HTML, which will be displayed.
* There is a filter applied to the search form HTML in order to edit or replace
* it. The filter is {@see 'get_search_form'}.
*
* This function is primarily used by themes which want to hardcode the search
* form into the sidebar and also by the search widget in WordPress.
*
* There is also an action that is called whenever the function is run called,
* {@see 'pre_get_search_form'}. This can be useful for outputting JavaScript that the
* search relies on or various formatting that applies to the beginning of the
* search. To give a few examples of what it can be used for.
/data/websites/telefonino/web/app/themes/telefonino/src/Features/CustomRSS.php
// Set Microsoft Start Feed RSS
add_feed( 'msstart', [ $this, 'msstartRSSFunc' ]);
// Set Feed RSS for punto-informatico.it
add_feed( 'exported', [ $this, 'exportedRSSFunc' ]);
add_feed( 'nooffers', [ $this, 'noOffersFunc' ]);
add_feed( 'inoreader', [ $this, 'inoReaderFunc' ] );
}
function googlenewsRSSFunc() { get_template_part('rss', 'googlenews'); }
function msstartRSSFunc() { get_template_part('rss', 'msstart' ); }
function updayRSSFunc() { get_template_part('rss', 'upday' ); }
function flipboardRSSFunc() { get_template_part('rss', 'flipboard' ); }
function exportedRSSFunc() { get_template_part('rss', 'exported' ); }
function noOffersFunc() { get_template_part('rss', 'nooffers' ); }
function inoReaderFunc() { get_template_part('rss', 'inoreader' ); }
}
/data/websites/telefonino/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/telefonino/web/wp/wp-includes/class-wp-hook.php
} 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.
*/
public function do_action( $args ) {
$this->doing_action = true;
$this->apply_filters( '', $args );
// If there are recursive calls to the current action, we haven't finished it until we get to the last one.
if ( ! $this->nesting_level ) {
$this->doing_action = false;
}
}
/**
* Processes the functions hooked into the 'all' hook.
*
* @since 4.7.0
*
* @param array $args Arguments to pass to the hook callbacks. Passed by reference.
*/
public function do_all_hook( &$args ) {
$nesting_level = $this->nesting_level++;
$this->iterations[ $nesting_level ] = $this->priorities;
do {
$priority = current( $this->iterations[ $nesting_level ] );
/data/websites/telefonino/web/wp/wp-includes/plugin.php
if ( ! isset( $wp_filter[ $hook_name ] ) ) {
if ( isset( $wp_filter['all'] ) ) {
array_pop( $wp_current_filter );
}
return;
}
if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $hook_name;
}
if ( empty( $arg ) ) {
$arg[] = '';
} elseif ( is_array( $arg[0] ) && 1 === count( $arg[0] ) && isset( $arg[0][0] ) && is_object( $arg[0][0] ) ) {
// Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
$arg[0] = $arg[0][0];
}
$wp_filter[ $hook_name ]->do_action( $arg );
array_pop( $wp_current_filter );
}
/**
* Calls the callback functions that have been added to an action hook, specifying arguments in an array.
*
* @since 2.1.0
*
* @see do_action() 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_actions Stores the number of times each action 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 action to be executed.
* @param array $args The arguments supplied to the functions hooked to `$hook_name`.
*/
function do_action_ref_array( $hook_name, $args ) {
/data/websites/telefonino/web/wp/wp-includes/functions.php
/**
* Fires once the given feed is loaded.
*
* The dynamic portion of the hook name, `$feed`, refers to the feed template name.
*
* Possible hook names include:
*
* - `do_feed_atom`
* - `do_feed_rdf`
* - `do_feed_rss`
* - `do_feed_rss2`
*
* @since 2.1.0
* @since 4.4.0 The `$feed` parameter was added.
*
* @param bool $is_comment_feed Whether the feed is a comment feed.
* @param string $feed The feed name.
*/
do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed );
}
/**
* Loads the RDF RSS 0.91 Feed template.
*
* @since 2.1.0
*
* @see load_template()
*/
function do_feed_rdf() {
load_template( ABSPATH . WPINC . '/feed-rdf.php' );
}
/**
* Loads the RSS 1.0 Feed Template.
*
* @since 2.1.0
*
* @see load_template()
*/
/data/websites/telefonino/web/wp/wp-includes/template-loader.php
// Process feeds and trackbacks even if not using themes.
if ( is_robots() ) {
/**
* Fired when the template loader determines a robots.txt request.
*
* @since 2.1.0
*/
do_action( 'do_robots' );
return;
} elseif ( is_favicon() ) {
/**
* Fired when the template loader determines a favicon.ico request.
*
* @since 5.4.0
*/
do_action( 'do_favicon' );
return;
} elseif ( is_feed() ) {
do_feed();
return;
} elseif ( is_trackback() ) {
require ABSPATH . 'wp-trackback.php';
return;
}
if ( wp_using_themes() ) {
$tag_templates = array(
'is_embed' => 'get_embed_template',
'is_404' => 'get_404_template',
'is_search' => 'get_search_template',
'is_front_page' => 'get_front_page_template',
'is_home' => 'get_home_template',
'is_privacy_policy' => 'get_privacy_policy_template',
'is_post_type_archive' => 'get_post_type_archive_template',
'is_tax' => 'get_taxonomy_template',
'is_attachment' => 'get_attachment_template',
'is_single' => 'get_single_template',
'is_page' => 'get_page_template',
/data/websites/telefonino/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/telefonino/web/index.php
<?php
/**
* WordPress View Bootstrapper
*/
define('WP_USE_THEMES', true);
require __DIR__ . '/wp/wp-blog-header.php';