Installation
- Upload the
lh-save-downfolder to/wp-content/plugins/. - Run
composer installinside the plugin directory (or use the LH MCPrun-composerability) to install mPDF and PHPePub intovendor/. - Activate the plugin.
- Resave your permalinks (Settings, Permalinks) so the export feeds are registered.
Adding download links
- Classic menus: Plain HTML, Plain Text, PDF and Epub appear as menu items under Appearance, Menus.
- Navigation blocks: the same four links are available by name in a navigation block’s inserter.
Shown on a single post or page, each link points at a signed download of that page in its format, with rel="nofollow". On archives and other screens with no single post it is left out.
Export URLs
Each format is a WordPress feed on the post’s permalink: lh-save_down.html, lh-save_down.text, lh-save_down.pdf and lh-save_down.epub. A request must also carry a valid lh_save_down-token query argument. The token is an HMAC of the post ID, the format and an expiry time, so it isn’t tied to any user or session and works until it expires. A request without a valid token gets an uncached 404. Build URLs through a menu or navigation link or through the get-export-url ability, rather than by hand.
What is exported
When the block template displaying a post marks a document region (a block with the class lh-md-content) and LH Content Converter 2.3.0+ is active, the export renders that region, which carries its own title. Otherwise it renders the post title followed by the post content. PDF and EPUB document titles and file names always come from the post title.
Customising the output
Copy a template from the plugin’s templates/ directory to the root of the active theme or child theme and edit it there. The plugin uses the theme’s copy when one exists:
lh_save_down-html-post_template.php: HTML, and EPUB, which wraps the same markup as XHTML.lh_save_down-pdf-post_template.php: PDF.lh_save_down-text-post_template.php: plain text.
Filters
lh_save_down_token_ttl: how long an export link stays valid, in seconds. DefaultDAY_IN_SECONDS.lh_save_down_get_template_location: the template file path for a format ($location, $format).lh_save_down_get_site_lang: the language declared in exports. Defaults toget_bloginfo( 'language' ).lh_save_down_auto_script_to_lang: turns on mPDF’s per-character script detection for multilingual content. Off by default because it is expensive; the PDF already picks a font for the site language.lh_save_down_return_plugin_debugging_status: debug logging.
