*/ 'interval' => apply_filters( '90min_leap_interval', MINUTE_IN_SECONDS * 30 ), 'display' => __( '90Min Leap', '90min' ), ); return $schedules; } public static function init() { add_action( '90min_fetch_new_posts', array( __CLASS__, 'do_fetch_new_posts' ) ); // leap interval default add_filter( '90min_leap_interval', array( __CLASS__, 'filter_90min_leap_interval' ) ); } public static function filter_90min_leap_interval() { return MINUTE_IN_SECONDS * 10; } public static function do_fetch_new_posts() { // figure out what calls we need to make $filtered = NM_Util::sepearate_leagues_teams( MC_90min_Settings_Controls::get_option( 'leagues' ) ); $categories = MC_90min_Settings_Controls::get_option( 'categories' ); if ( !empty($categories) ) { $filtered['category'] = $categories; } // fetch all feeds if ( empty($filtered) ) return; $log = array(); $inserted_in_session = 0; foreach ( $filtered as $type => $list ) { if ( empty($list) ) continue; foreach ( $list as $id ) { $feed_posts = NM_Dispatcher::fetch_feed( $type, $id ); $feed_posts_count = count($feed_posts); $total_inserted = NM_Data_Bridge::process_feed( $feed_posts ); $inserted_in_session += $total_inserted; $_feed_or_category_label = ( $type === 'category' ) ? 'Category' : 'Feed'; $log[] = "$_feed_or_category_label ID $id fetched. Inserted: $total_inserted/$feed_posts_count "; } } // last updated feed time update_option( '90min_last_feed_fetched', array( 'time' => time(), 'log' => $log, 'inserted_in_session' => $inserted_in_session, ) ); NM_Util::log_errors($log); } }