DOCS

QR Codes

Fundations generates QR codes server-side using the Endroid QR Code library. No external API calls are made. QR codes are cached in WordPress transients. This is a free feature.

Qr code on fundraising page

Why use this

QR codes let fundraisers share their page in physical spaces: printed flyers, posters, event programmes. Scanning the code takes a donor directly to the donation form. Server-side generation means no data is sent to third-party services.

What it does

The get-fund/qr-code block renders a QR code encoding the URL of the current fundraising page. The code is generated as a PNG data URI by Get_Fund_QR_Generator::generate() and cached indefinitely in a transient keyed by get_qr_{md5(url+size)}.

Generation settings

SettingDefaultDescription
Size256QR code size in pixels
Margin10Quiet zone margin in pixels
Foreground color[0, 0, 0] (black)RGB array
Background color[255, 255, 255] (white)RGB array
Error correctionHighEndroid ErrorCorrectionLevel::High

All settings are filterable via get_fund_qr_settings.

Fallback

If the Endroid library is unavailable or throws an exception, a fallback SVG is returned showing “QR Code Generation Failed” with a short excerpt of the encoded URL. The block never crashes the page.

How to use it

  1. Open a fundraising page in the block editor.
  2. Add the QR Code block from the Fundations block category.
  3. The block automatically encodes the current page URL.
  4. Save the page. The QR code renders on the frontend.
Qr code block editor

What you can and cannot do

You can encode any URL by filtering get_fund_qr_data before generation, and change the QR code colors, size, and margin via get_fund_qr_settings. To invalidate a cached QR code, delete the transient get_qr_{md5(url+size)}.

You cannot generate QR codes with embedded logos or custom shapes. The library is configured for standard matrix QR codes only. Output format is PNG (data URI); the fallback returns SVG only on error.

Troubleshooting

QR code shows “Generation Failed” SVG. The Endroid QR Code library may not be installed. Run composer install in the plugin directory. If the plugin was installed from wordpress.org, confirm the vendor directory is present.

Scanning the QR code goes to the wrong URL. The cached data URI encodes the URL at the time of first generation. If the page permalink changed, delete the relevant transient or clear all transients to force regeneration.

Developer reference

Filters

HookArgumentsDescription
get_fund_qr_datastring $data, int $sizeModify the string (URL) encoded in the QR code before generation.
get_fund_qr_settingsarray $settings, string $dataModify QR code generation settings: size, margin, foreground_color, background_color.

Example: encode a custom URL

add_filter( 'get_fund_qr_data', function( $data, $size ) {
    // Replace the URL with a tracked short link
    return 'https://example.com/track?url=' . urlencode( $data );
}, 10, 2 );