Опис
Effortless QR Code Generator is a WordPress plugin that allows you to create QR codes using a simple shortcode. It supports both client-side JavaScript rendering and server-side PHP rendering.
Features
- Simple shortcode: Use
[effortless_qrcode url="https://example.com"]to generate QR codes - Dual rendering modes: Client-side (JavaScript) or server-side (PHP/PNG)
- Developer API: Generate QR codes programmatically from your plugins/themes
- Customizable size: Control QR code dimensions (100-500 pixels)
- Custom colors: Set dark and light colors for the QR code
- Error correction levels: Choose L, M, Q, or H
- Cached PNG images: Server-rendered QR codes are cached in the uploads folder
- Responsive design: QR codes adapt to different screen sizes
- No external dependencies: All code is bundled locally
- Privacy-friendly: No data sent to external services
- Accessibility ready: Proper alt text support
- Performance optimized: Scripts load only when needed
Shortcode Parameters
url– The URL to encode (required)size– Size in pixels (default: 150, min: 100, max: 500)color_dark– Dark color in hex format (default: #000000)color_light– Light color in hex format (default: #ffffff)render– Rendering mode: “client” or “server” (default: client)ecc– Error correction level: L, M, Q, H (default: M)alt– Alt text for accessibility (server rendering only)class– Additional CSS class (server rendering only)data– Arbitrary data to encode (plain text, WiFi, vCard, etc.). When set, overridesurland disableslinklink– Wrap QR code in a clickable link: “yes” or “no” (default: no). Only works with URL content, ignored whendatais usedtitle– Tooltip text shown on hovertarget– Link target attribute: “_blank”, “_self”, etc. (default: _blank)
Usage Examples
Basic usage (client-side):
[effortless_qrcode url=”https://example.com”]
Server-side rendering:
[effortless_qrcode url=”https://example.com” render=”server”]
With custom size and colors:
[effortless_qrcode url=”https://example.com” size=”200″ color_dark=”#0073aa”]
Server-side with high error correction:
[effortless_qrcode url=”https://example.com” render=”server” ecc=”H” alt=”Scan me”]
PHP API for Developers
Third-party plugins and themes can generate QR codes programmatically using the Effortless_QRCode_Native class.
Basic Usage:
<?php
// Make sure the plugin is active
if ( class_exists( 'Effortless_QRCode_Native' ) ) {
// Generate a QR code PNG
$result = Effortless_QRCode_Native::generate_png( 'https://example.com' );
if ( $result ) {
echo '<img src="' . esc_url( $result['url'] ) . '" alt="QR Code">';
}
}
?>
With Custom Options:
<?php
$result = Effortless_QRCode_Native::generate_png(
'https://example.com', // Data to encode (required)
200, // Size in pixels (default: 150)
'#0073aa', // Dark color (default: #000000)
'#ffffff', // Light color (default: #ffffff)
'H', // ECC level: L, M, Q, H (default: M)
4 // Margin in modules (default: 4)
);
if ( $result ) {
// $result['url'] - Public URL to the PNG image
// $result['path'] - Server filesystem path to the PNG file
// $result['debug'] - Debug information string
}
?>
Display in a Template:
<?php
if ( class_exists( 'Effortless_QRCode_Native' ) ) {
$result = Effortless_QRCode_Native::generate_png( get_permalink() );
if ( $result ) : ?>
<div class="my-qr-code">
<img src="<?php echo esc_url( $result['url'] ); ?>"
alt="<?php esc_attr_e( 'Scan to visit this page', 'my-theme' ); ?>"
width="150"
height="150">
</div>
<?php endif;
}
?>
API Reference
Effortless_QRCode_Native::generate_png( $data, $size, $color_dark, $color_light, $ecc, $margin )
Generates a QR code PNG image and saves it to the WordPress uploads folder.
Parameters:
$data(string) – Required. The data to encode (URL, text, etc.)$size(int) – Optional. Image size in pixels. Default: 150$color_dark(string) – Optional. Hex color for dark modules. Default: ‘#000000’$color_light(string) – Optional. Hex color for light modules. Default: ‘#ffffff’$ecc(string) – Optional. Error correction level (L, M, Q, H). Default: ‘M’$margin(int) – Optional. Quiet zone margin in modules. Default: 4
Returns:
Array on success with keys:
* url – Public URL to the generated PNG image
* path – Server filesystem path to the PNG file
* debug – Debug information string
Returns false on failure.
Notes:
- Images are cached based on all parameters (same input = same file)
- Files are stored in
wp-content/uploads/effortless-qrcodes/ - Requires GD library for PNG generation
Error Correction Levels
- L – 7% recovery capacity (smallest QR code)
- M – 15% recovery capacity (default, good balance)
- Q – 25% recovery capacity
- H – 30% recovery capacity (largest QR code, best for print)
Higher error correction allows the QR code to be read even if partially damaged or obscured.
Privacy
This plugin does not collect, store, or transmit any personal data. QR codes are generated locally (either in the browser or on your server).
Requirements
- PHP 7.4+ with GD library (for server-side PNG generation)
- WordPress 5.0+
- JavaScript enabled (for client-side rendering only)
Встановлення
Automatic Installation
- Go to your WordPress admin area and navigate to Plugins > Add New
- Search for “Effortless QR Code Generator”
- Click “Install Now” and then “Activate”
Manual Installation
- Download the plugin zip file
- Upload the
effortless-qr-code-generatorfolder to/wp-content/plugins/ - Activate the plugin through the ‘Plugins’ menu in WordPress
After Installation
- Use the shortcode
[effortless_qrcode url="your_url"]in any post, page, or widget - Customize the appearance using the available parameters
- Check Settings > QR Code Generator for usage information
Часті питання
-
Why is my QR code not displaying?
-
Make sure:
- You’ve provided a valid URL in the shortcode
- JavaScript is enabled in your browser (for client-side rendering)
- There are no JavaScript conflicts with other plugins
- For server-side rendering, ensure the GD library is installed
-
What’s the difference between client and server rendering?
-
Client-side (default): QR codes are generated in the browser using JavaScript. Requires JavaScript enabled.
Server-side: QR codes are generated on your server as PNG images. Better for SEO and works without JavaScript. Requires GD library.
-
Can I customize the QR code colors?
-
Yes! Use the
color_darkandcolor_lightparameters:
[effortless_qrcode url=”https://example.com” color_dark=”#0073aa” color_light=”#ffffff”] -
What’s the maximum size for QR codes?
-
The maximum size is 500 pixels. The minimum size is 100 pixels to ensure reliable scanning.
-
Does this plugin work with caching plugins?
-
Yes. Server-side rendered QR codes are saved as PNG files and cached automatically.
-
Is this plugin GDPR compliant?
-
Yes, the plugin doesn’t collect, store, or transmit any personal data.
-
Can I use this in widgets?
-
Yes, the shortcode works in text widgets and any area that supports shortcodes.
-
Can I generate QR codes from my plugin or theme?
-
Yes! Use the PHP API:
<?php if ( class_exists( 'Effortless_QRCode_Native' ) ) { $result = Effortless_QRCode_Native::generate_png( 'https://example.com' ); if ( $result ) { echo '<img src="' . esc_url( $result['url'] ) . '" alt="QR Code">'; } } ?> -
Where are server-rendered QR codes stored?
-
PNG images are saved to
wp-content/uploads/effortless-qrcodes/. Files are cached based on their parameters, so identical QR codes reuse the same file.
Відгуки
Для цього плагіна немає відгуків.
Учасники та розробники
“EffortLess QR Code Generator” — проект з відкритим вихідним кодом. В розвиток плагіну внесли свій вклад наступні учасники:
УчасникиПерекладіть “EffortLess QR Code Generator” на вашу мову.
Цікавитесь розробкою?
Перегляньте код, перегляньте сховище SVN або підпишіться на журнал розробки за допомогою RSS.
Журнал змін
1.4.3
- SECURITY: Replaced innerHTML with textContent for error messages to prevent DOM-based XSS
- SECURITY: Added URL scheme validation (https/http only) before creating clickable links in JavaScript
- SECURITY: Added .htaccess with Options -Indexes to cache directory for Apache directory listing protection
1.4.2
- FIXED: Double-escaping of CSS class attribute on server-rendered QR codes
- FIXED:
is_plugin_active_for_network()availability when sites are created via WP-CLI - IMPROVED: Client-side containers now reserve space to prevent layout shift (CLS)
- IMPROVED: Server-rendered images use
loading="lazy"for better performance - IMPROVED: QR code images and canvas scale down on narrow screens (
max-width: 100%) - IMPROVED: Cache key includes plugin version to prevent stale images after updates
- IMPROVED: Fallback for hosts where
glob()is disabled - IMPROVED: Deduplicated script/style enqueue logic into shared method
- IMPROVED: Server-side error messages show generic text to non-admin visitors
1.4.1
- FIXED: QR code generation for data longer than 271 characters (complete RS block table for versions 1-40)
- FIXED: Server-side rendering of non-ASCII characters (UTF-8 double-encoding bug)
- FIXED:
dataparameter now preserves newlines for vCard, WiFi, and other multi-line formats - FIXED: Minimum QR code size enforced at 100px to match documentation
- FIXED: Translations now load correctly via
load_plugin_textdomain() - FIXED: Client-side link wrapping now handles async QR library rendering
- FIXED: Network-wide deactivation now runs on all sites
- IMPROVED: Per-site upgrade routine ensures updates apply across multisite networks
- IMPROVED: Cache directory now includes
index.phpto prevent directory listing - IMPROVED: Automatic cache cleanup removes files older than 30 days and caps at 1000 files
- IMPROVED: Uninstall now removes generated QR code PNG files and cache directory
- IMPROVED:
targetattribute validated against allowed values - IMPROVED: Scripts load correctly when shortcode is used via
do_shortcode()in templates - IMPROVED: Removed console.log statements from production JavaScript
- IMPROVED: Full PHPCS/WPCS and PHPCompatibility compliance
- IMPROVED: Regenerated POT file with correct line references
1.4.0
- NEW: Full multisite support with network-wide activation and per-site cleanup on uninstall
- NEW: Translation-ready JavaScript strings via wp_localize_script
- NEW: POT file for translators at languages/effortless-qr-code-generator.pot
- IMPROVED: Automatic setup for new sites created on a multisite network
1.3.0
- NEW:
dataparameter to encode arbitrary content (plain text, WiFi, vCard, etc.) - NEW:
linkparameter to wrap QR code in a clickable link - NEW:
titleparameter for tooltip text on hover - NEW:
targetparameter to control link target attribute
1.2.1
- FIXED: Server-side rendering now correctly displays PNG images
- FIXED: JavaScript no longer overwrites server-rendered QR codes
- IMPROVED: Added data-rendered attribute to prevent client-side processing of server QR codes
- IMPROVED: Cleaned up codebase, removed unused SVG generation code
1.2.0
- NEW: Native PHP QR code generator – no external library required
- NEW: Server-side rendering now works on PHP 7.4+
- NEW: PNG images saved to uploads folder with automatic caching
- FIXED: QR codes now always readable – added color contrast validation
- FIXED: Minimum size increased from 50px to 100px for reliable scanning
- IMPROVED: Better scale calculation based on actual data length
1.1.0
- NEW: Server-side PHP rendering with
render="server"attribute - NEW: PHP API for developers to generate QR codes programmatically
- NEW: Error correction level support (L, M, Q, H)
- Added: Comprehensive admin page with API documentation
- Improved: Accessibility with proper alt text support
1.0.1
- Fix names in readme.txt
1.0.0
- Initial release
- Basic QR code generation functionality
- Responsive design
- Color customization
- Size control
