includes/staticwp.class.php
public function updateHtml($id, $post = null)
    {
        if ($post != null && $post->post_status != 'publish') {
            return;
        }

        $permalink = get_permalink($id);
        $uri = substr($permalink, strlen(get_option('home')));
        $filename = $this->destination . $uri . 'index.html';
        $dir = $this->destination . $uri;

        if (!is_dir($dir)) {
            wp_mkdir_p($dir);
        }

        if (is_file($filename)) {
            unlink($filename);
        }

        $curl = curl_init($permalink);

        curl_setopt($curl, CURLOPT_HEADER,         false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

        $data = null;
        if (($data = curl_exec($curl)) === false) {
            throw new Exception(sprintf('Curl error: %s', curl_error($curl)));
        }

        curl_close($curl);
        do_action('staticwp_pre_cache_update', $id);
        file_put_contents($filename, apply_filters('staticwp_cache_update_contents', $data, $id));
        do_action('staticwp_post_cache_update', $id);
    }
public function updateHtml($id, $post = null)
    {
        if ($post != null && $post->post_status != 'publish') {
            return;
        }

        $permalink = get_permalink($id);
        $uri = substr($permalink, strlen(get_option('home')));
        $filename = $this->destination . $uri . 'index.html';
        $dir = $this->destination . $uri;

        if (!is_dir($dir)) {
            wp_mkdir_p($dir);
        }

        if (is_file($filename)) {
            unlink($filename);
        }

        $curl = curl_init($permalink);

        curl_setopt($curl, CURLOPT_HEADER,         false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

        $data = null;
        if (($data = curl_exec($curl)) === false) {
            throw new Exception(sprintf('Curl error: %s', curl_error($curl)));
        }

        curl_close($curl);
        do_action('staticwp_pre_cache_update', $id);
        file_put_contents($filename, apply_filters('staticwp_cache_update_contents', $data, $id));
        do_action('staticwp_post_cache_update', $id);
    }
public function updateHtml ( $ id , $ post = null ) { if ( $ post != null && $ post -> post_status != 'publish' ) { return ; } $ permalink = get_permalink ( $ id ) ; $ uri = substr ( $ permalink , strlen ( get_option ( 'home' ) ) ) ; $ filename = $ this -> destination . $ uri . 'index.html' ; $ dir = $ this -> destination . $ uri ; if ( ! is_dir ( $ dir ) ) { wp_mkdir_p ( $ dir ) ; } if ( is_file ( $ filename ) ) { unlink ( $ filename ) ; } $ curl = curl_init ( $ permalink ) ; curl_setopt ( $ curl , CURLOPT_HEADER , false ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; $ data = null ; if ( ( $ data = curl_exec ( $ curl ) ) === false ) { throw new Exception ( sprintf ( 'Curl error: %s' , curl_error ( $ curl ) ) ) ; } curl_close ( $ curl ) ; do_action ( 'staticwp_pre_cache_update' , $ id ) ; file_put_contents ( $ filename , apply_filters ( 'staticwp_cache_update_contents' , $ data , $ id ) ) ; do_action ( 'staticwp_post_cache_update' , $ id ) ; }
Updates the static HTML for a post.

@since 1.0.0
@param int           $id
@param \WP_Post|null $post

@return void
Updates the static HTML for a post .