Export / save static copies of all your WordPress URLs.
This plugin is very specific in what it offers, that is - saving (almost) all URLs that can be publicly viewed on a WordPress site to another directory. This can be used in conjunction with different Stream Wrappers to upload to locations on S3, FTP etc.
The plugin essentials works like so:
- Get all the URLs that exist on the site via
get_posts
,get_terms
etc etc. - Generate the public markup from each URL.
- Perform any replacements on the content such as transforming URLs.
- Save the pages to a directory, preserving the original path.
This can be triggered via WP CLI Commands, or via cron when content on the WordPress site is updated.
Get the output of a single page, for testing
wp static-page output http://wordpress.dev/ [--replace-from=<from>] [--replace-to=<to>]
List all URLs that Static Page knows about
wp static-page urls
Save the site to static files
wp static-page save [--replace-from=<from>] [--replace-to=<to>]
List all assets that Static Page knows about
wp static-page assets
Save all assets out
wp static-page save-assets
Static Page is meant to be require little configuration, in the case than you do need to configure this, you can use the following hooks:
Add / remove URLs that are generated
add_filter( 'static_page_site_urls', function ( $urls ) {
$urls[] = site_url( '/my-hidden-url/' );
return $urls;
});
Make custom URL replacements on the contents of pages
add_filter( 'static_page_replace_urls_in_content', function ( $page_markup ) {
return str_replace( site_url(), 'https://my-cdn.example.com/', $page_markup );
});
Add / remove assets directories to be copied on save-assets
All files of type jpg
, css
, js
, png
, gif
will be copied from the directories.
add_filter( 'static_page_assets_dirs', function ( $dirs ) {
$dirs[] = plugin_dir( 'akismet' );
return $dirs;
});