File_Exists For Remote URL

If you want to make sure that a file exists in PHP you can use the function file_exists(), which takes one parameter of the filename.
// Returns true if the file exists
file_exists( $filename );
This function will not only work for files but will also work for directories, you can pass in a filename of the directory and if this directory exists the file_exists() function will return true.
<?php
$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
?>
The problem I've seen with this function is that people have tried to use it when they want to see if a remote file exists using a URL. But if you try to search for a file exists using this function with a URL it will not work correctly, the function will always return false.
If you want to check if the file_exists() with a remote URL you need to make a HTTP request for this file and check what the HTTP header status are when the request returns.

Get Headers Of A URL

To get the headers of a remote file then you can use the PHP function of get_headers(). This takes a parameter of the URL you want to request and it will return an array of the headers returned. The first key of the array is the value we are interested in, this will return the header status of the HTTP. If the file exists the status will return a 200 code, if the remote file doesn't exist then the status will return a 404 error.
This means we can use function to check if the remote file exists.
$file_headers = @get_headers($url);
if($file_headers[0] == 'HTTP/1.0 404 Not Found')
{
   $file_exists = false;
} else {
   $file_exists = true;
}

Redirect HTTP to HTTPS

Since Google announced that they were going to start using HTTPS as part of their ranking you would of seen a vast amount of websites switching to use HTTPS instead of using HTTP.
If you are switching your site to use HTTPS you need to remember that all your pages that are indexed into Google or websites that are linking to your site will still be pointing to your old HTTP page. Therefore you need to make sure that you redirect all non-HTTPS pages to HTTPS.

Redirect With htaccess

If you are using an apache server then you can use the following code snippet and enter it into your htaccess file.
This will search for anything coming in on port 80 which is the default for HTTP and will redirect it to HTTPS.
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://{HTTP_HOST}/$1 [R=301,L]

Redirect On Nginx

If you are using an Nginx then you can add the following into your server conf. This will listen to requests on port 80 and redirect to your server with a HTTPS prefix, all you have to do is replace theexample.com with your own domain.
server {
    listen      80;
    server_name example.com;
    return 301   https://$server_name$request_uri;
}

WordPress Recent Posts Shortcode

On WordPress.com you automatically get are a large number of shortcodes that you can use on your blog. Here you can view all the default shortcodes on WordPress.com.
One of these shortcodes is to display the most recent posts by using the shortcode display posts.
The below is a code snippet you can use to add a list of the most recent posts and the date they were published. This shortcode displays the last 10 posts in a list anywhere you use the shortcode. The attributes on the shortcode will be passed into the WP_Query object therefore if you want to change what posts are displayed by simply changing the attributes on the shortcode.
/**
 * Shortcode to display the most recent posts
 * The attributes passed into the function will be passed into the WP_Query object to modify the query
 * By default the last 10 posts will be displayed
 * 
 * @param $atts
 * @param $content
 * 
 * @return string
 */
function pu_recent_posts_shortcode($atts, $content = NULL)
{
    $atts = shortcode_atts(
        [
            'orderby' => 'date',
            'posts_per_page' => '10'
        ], $atts, 'recent-posts' );
    
    $query = new WP_Query( $atts );

    $output = '<ul class="recent-posts">';

    while($query->have_posts()) : $query->the_post();

        $output .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a> - <small>' . get_the_date() . '</small></li>';

    endwhile;

    wp_reset_query();

    return $output . '</ul>';
}
add_shortcode('recent-posts', 'pu_recent_posts_shortcode');