| Server IP : 104.21.21.239 / Your IP : 216.73.217.54 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/newmandy/wp-content/wp-rss-aggregator/includes/ |
Upload File : |
<?php
/**
* Fetches feed items from sources provided
* DEPRECATED - JUST FOR REFERENCE
*
* @since 2.0
* @deprecated 3.0
*/
/*function wprss_fetch_all_feed_items( ) {
// Get all feed sources
$feed_sources = new WP_Query( array(
'post_type' => 'wprss_feed',
'post_status' => 'publish',
'posts_per_page' => -1,
) );
if( $feed_sources->have_posts() ) {
/* Start by getting one feed source, we will cycle through them one by one,
fetching feed items and adding them to the database in each pass */
/* while ( $feed_sources->have_posts() ) {
$feed_sources->the_post();
$feed_ID = get_the_ID();
$feed_url = get_post_meta( get_the_ID(), 'wprss_url', true );
// Use the URL custom field to fetch the feed items for this source
if( !empty( $feed_url ) ) {
add_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
//$feed = fetch_feed( $feed_url );
$feed = wprss_fetch_feed( $feed_url, $feed_ID );
remove_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
// $feed->strip_htmltags( array_merge( $feed->strip_htmltags, array('h1', 'a', 'img') ) );
if ( !is_wp_error( $feed ) ) {
// Figure out how many total items there are, but limit it to 10.
$maxitems = $feed->get_item_quantity(10);
// Build an array of all the items, starting with element 0 (first element).
$items = $feed->get_items( 0, $maxitems );
}
else { return; }
}
if ( ! empty( $items ) ) {
// Gather the permalinks of existing feed item's related to this feed source
global $wpdb;
$existing_permalinks = $wpdb->get_col(
"SELECT meta_value
FROM $wpdb->postmeta
WHERE meta_key = 'wprss_item_permalink'
AND post_id IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_value = $feed_ID)
");
foreach ( $items as $item ) {
// Check if newly fetched item already present in existing feed item item,
// if not insert it into wp_posts and insert post meta.
if ( ! ( in_array( $item->get_permalink(), $existing_permalinks ) ) ) {
// Create post object
$feed_item = array(
'post_title' => $item->get_title(),
'post_content' => '',
'post_status' => 'publish',
'post_type' => 'wprss_feed_item'
);
$inserted_ID = wp_insert_post( $feed_item );
wprss_items_create_post_meta( $inserted_ID, $item, $feed_ID );
} //end if
} //end foreach
} // end if
} // end $feed_sources while loop
wp_reset_postdata(); // Restore the $post global to the current post in the main query
// } // end if
} // end if
}
// For testing query speed
// $time_start = microtime( true );
// wp_die(number_format( microtime( true ) - $time_start, 10 ));
*/