Extending the plugin
The plugin is built to be extended through filters rather than by editing or forking it. The Pro version is built the same way: it subclasses the public renderer and contributes through these seams.
The two layers a document passes through
Section titled “The two layers a document passes through”- Source detection decides what a URL is: its extension, whether it is an embeddable service, and what embed URL it maps to. One class,
WCDP_Document_Source, answers this for both the admin and the front end, so they cannot disagree about whether a link will render. - Renderer resolution decides how a document is shown. PDFs render locally through pdf.js; other formats route to the Google viewer.
WCDP_Rendereranswers this.
Add a document service
Section titled “Add a document service”Filter wcdp_document_sources to add a cloud service. Add a key with patterns (regular expressions), an embed_template, and a type. Do not ship a second detector; this is the one place detection lives.
Add or restrict file formats
Section titled “Add or restrict file formats”Filter wcdp_supported_extensions to change which uploaded file types are eligible. Return the full list you want. Pro answers this filter to remove formats a store owner deselected, and preserves any format that setting never offered, so it does not discard other extensions on the hook.
Supply your own viewer
Section titled “Supply your own viewer”Answer wcdp_renderer_for_document with your own renderer key, then handle that key when the preview URL is built. A local viewer, like the bundled pdf.js one, is what makes page limits, watermarks, and download protection possible, none of which can be done inside a third party iframe.
Change where the preview appears
Section titled “Change where the preview appears”wcdp_preview_hookmoves the automatic placement to a different WooCommerce action. The default fires inside the add to cart form; a fallback onwoocommerce_single_product_summaryat priority 35 catches products with no form, and renders only when nothing has rendered yet, so changing the filter does not produce two previews.- The shortcode and the block place the preview anywhere, including themes that never fire the WooCommerce hook.
wcdp_load_assetsopts a page into the stylesheet and script.
Take over rendering
Section titled “Take over rendering”wcdp_public_instance replaces the renderer object outright, which is how Pro takes over. Prefer a template override to reimplementing a render method: a theme override is silently dead if an extension re-authors the markup instead of using the template.
Read the data
Section titled “Read the data”Read a product’s documents through WCDP_Documents::get( $product_id ), which returns a normalised list of name and url. It accepts both the current and the legacy Pro URL sub-key, so no store loses its documents across a free to Pro move.

