10, // Number of recent posts thumbnails to display 'post_status' => 'publish' // Show only the published posts )); foreach( $recent_posts as $recent ) { if ( has_post_thumbnail($recent['ID']) ) { // check if the post has a Post Thumbnail assigned to it. echo "
"; echo "New on spring2life "; echo get_the_post_thumbnail($recent['ID'],'thumbnail', 'style=float:right;') . "
"; break; } } } function debug_echo ( $text ) { /* if ( false ) { */ /* echo 'debug:
\n"; */ echo 'debug: ', $text, "
\n"; /* } */ } function insert_chunk_before( $before, $newest_only, $chunk ) { return preg_replace("/<\/ul>\n
  • $before<\/h4>/", "
  • $chunk
  • \n\n
  • $before

    ", $newest_only); } function process_oren_grad($chunk, $newest_only, $omitflag) { $chunk = preg_replace('#
    .*
    #s', '', $chunk); $chunk = preg_replace('##s', '', $chunk); $now = date_timestamp_get(date_create()); if ( false === ( $og = get_transient( 'orengrad' ) ) ) { /* no transient could be restored */ $result = curlDownload('http://orengrad.com/thingsseen/index.html'); $og[1] = md5($result); $og[0] = $now; set_transient('orengrad', $og); } else { /* there is a transient */ if ( $now - $og[0] > 1*3600 ) { /* timestamp older than 12h, so compare again */ $oldhash = $og[1]; $result = curlDownload('http://orengrad.com/thingsseen/index.html');/* nochmal holen */ $og[1] = md5($result); if ( $og[1] <> $oldhash ) { /* not equal, so save again */ $og[0] = $now; set_transient('orengrad', $og);/* set transient with new timestamp */ /* } else { debug_echo('Hashes are equal'); */ } } } $diff_in_seconds = date_timestamp_get(date_create()) - $og[0]; echo ""; if ( $diff_in_seconds < 24 * 3600 ) { $newest_only = insert_chunk_before('A day and older', $newest_only, $chunk); } elseif ( $diff_in_seconds < 30 * 24 * 3600 ) { $newest_only = insert_chunk_before('Less than a month old', $newest_only, $chunk); } else { $newest_only = insert_chunk_before('Older', $newest_only, $chunk); } /* delete_transient('orengrad'); */ $omitflag = true; return array($newest_only, $omitflag); } function process_lfi_online($chunk, $newest_only, $omitflag) { $chunk = preg_replace('#
    .*
    #s', '', $chunk); $chunk = preg_replace('##s', '', $chunk); $matches = []; if ( false === ( $result = get_transient( 'lfionlinede' ) ) ) { $result = curlDownload('https://lfi-online.de/ceemes/en/blog/'); $chunk = str_replace('
    ', '', $chunk); if ( preg_match('#
    \s*

    (.*?)

    \s*\s*

    .*?

    \s*

    (.*?)

    #s', $result, $matches)) { $chunk = $chunk . ": \n\n$matches[2]"; set_transient('lfionlinede', $chunk, 12*3600); } } else { $chunk = $result; } /* delete_transient('lfionlinede'); */ /* Assumption: LFI comes in the last section of all entries, because it does not show a date to google. Therefore all headlines are already written to $newestonly and we can insert before */ /* $age_in_days = date_diff(date_create($matches[3]), date_create(date("d.m.Y")))->format('%a'); */ $age_in_days = date_diff(date_create($matches[3]), date_create(date("d.m.Y"))); debug_echo($matches[0]); /* debug_echo(date_create($matches[3])); */ /* debug_echo(date_create(date("d.m.Y"))); */ #echo ""; if ($age_in_days < 1) { $newest_only = insert_chunk_before('A day and older', $newest_only, $chunk); } elseif ($age_in_days < 30) { $newest_only = insert_chunk_before('Less than a month old', $newest_only, $chunk); } else { $newest_only = insert_chunk_before('Older', $newest_only, $chunk); } $omitflag = true; return array($newest_only, $omitflag); } function cleanup_chunk ( $chunk ) { $chunk = preg_replace("/[\s]*
    .*<\/div>/ism", "", $chunk); $chunk = preg_replace("/
    [\r\n]?/ism", "", $chunk); $chunk = preg_replace("/
    [\r\n]?/ism", "
  • ", $chunk); $chunk = preg_replace("/<\/div>[\r\n]?/ism", ": ", $chunk); $chunk = preg_replace("/<\/span>/ism", "
  • ", $chunk); return $chunk; } function blogs_i_read() { $url = "http://spring2life-links.blogspot.de"; if ( false === ( $html = get_transient( $url ) ) ) { $html = curlDownload($url); if ( ! $html ) { echo "

    There is a problem with the http request!

    "; } else { if ( ! preg_match('/(