| 1 |
<?php |
| 2 |
/** |
| 3 |
* QR Code Creator |
| 4 |
* |
| 5 |
* A WordPress plugin which will help you to create QR Codes. |
| 6 |
* |
| 7 |
* @package QRCodeCreator |
| 8 |
* @author Dhanendran Rajagopal |
| 9 |
* @copyright 2024 Dhanendran Rajagopal |
| 10 |
* @license GPL-2.0+ |
| 11 |
* |
| 12 |
* @wordpress-plugin |
| 13 |
* Plugin Name: QR Code Creator |
| 14 |
* Plugin URI: https://github.com/dhanendran/qr-code-creator |
| 15 |
* Description: Create QR codes directly in your WordPress admin — generated locally in the browser (no third-party API), with custom colors, error correction, a center logo, and PNG/SVG download. |
| 16 |
* Short Description: Create customizable QR codes locally (no external API) with colors, error correction, a center logo, and PNG/SVG export. |
| 17 |
* Version: 1.0.0 |
| 18 |
* Author: Dhanendran Rajagopal |
| 19 |
* Author URI: https://dhanendranrajagopal.me/ |
| 20 |
* License: GPL-2.0+ |
| 21 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 22 |
* Text Domain: qr-code-creator |
| 23 |
* Domain Path: /languages |
| 24 |
* Requires at least: 4.4 |
| 25 |
* Tested up to: 7.0 |
| 26 |
* Requires PHP: 7.4 |
| 27 |
*/ |
| 28 |
|
| 29 |
// If this file is called directly, abort. |
| 30 |
if ( ! defined( 'ABSPATH' ) ) { |
| 31 |
die; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Plugin version constant. |
| 36 |
* |
| 37 |
* @since 0.2.0 |
| 38 |
*/ |
| 39 |
define( 'QR_CODE_CREATOR_VERSION', '1.0.0' ); |
| 40 |
|
| 41 |
/** |
| 42 |
* Plugin directory path. |
| 43 |
* |
| 44 |
* @since 0.2.0 |
| 45 |
*/ |
| 46 |
define( 'QR_CODE_CREATOR_PATH', plugin_dir_path( __FILE__ ) ); |
| 47 |
|
| 48 |
/** |
| 49 |
* Plugin directory URL. |
| 50 |
* |
| 51 |
* @since 0.2.0 |
| 52 |
*/ |
| 53 |
define( 'QR_CODE_CREATOR_URL', plugin_dir_url( __FILE__ ) ); |
| 54 |
|
| 55 |
/** |
| 56 |
* The core plugin class. |
| 57 |
* |
| 58 |
* @since 0.1.0 |
| 59 |
*/ |
| 60 |
class QRCodeCreator { |
| 61 |
|
| 62 |
/** |
| 63 |
* Plugin version. |
| 64 |
* |
| 65 |
* @since 0.2.0 |
| 66 |
* @var string |
| 67 |
*/ |
| 68 |
private $version; |
| 69 |
|
| 70 |
/** |
| 71 |
* Admin instance. |
| 72 |
* |
| 73 |
* @since 0.2.0 |
| 74 |
* @var QRCodeCreator_Admin |
| 75 |
*/ |
| 76 |
private $admin; |
| 77 |
|
| 78 |
/** |
| 79 |
* Initialize the plugin. |
| 80 |
* |
| 81 |
* @since 0.1.0 |
| 82 |
*/ |
| 83 |
public function __construct() { |
| 84 |
$this->version = QR_CODE_CREATOR_VERSION; |
| 85 |
$this->load_dependencies(); |
| 86 |
$this->init_hooks(); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Load required dependencies. |
| 91 |
* |
| 92 |
* @since 0.2.0 |
| 93 |
*/ |
| 94 |
private function load_dependencies() { |
| 95 |
require_once QR_CODE_CREATOR_PATH . 'includes/class-qrcode-creator-admin.php'; |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Initialize hooks. |
| 100 |
* |
| 101 |
* @since 0.2.0 |
| 102 |
*/ |
| 103 |
private function init_hooks() { |
| 104 |
add_action( 'plugins_loaded', array( $this, 'init' ) ); |
| 105 |
register_activation_hook( __FILE__, array( $this, 'activate' ) ); |
| 106 |
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); |
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Initialize the plugin. |
| 111 |
* |
| 112 |
* @since 0.1.0 |
| 113 |
*/ |
| 114 |
public function init() { |
| 115 |
if ( is_admin() ) { |
| 116 |
$this->admin = new QRCodeCreator_Admin( $this->version ); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* Activation hook. |
| 122 |
* |
| 123 |
* @since 0.2.0 |
| 124 |
*/ |
| 125 |
public function activate() { |
| 126 |
// Add activation logic here if needed. |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* Deactivation hook. |
| 131 |
* |
| 132 |
* @since 0.2.0 |
| 133 |
*/ |
| 134 |
public function deactivate() { |
| 135 |
// Add deactivation logic here if needed. |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
/** |
| 140 |
* Initialize the plugin. |
| 141 |
* |
| 142 |
* @since 0.1.0 |
| 143 |
*/ |
| 144 |
function qr_code_creator_init() { |
| 145 |
new QRCodeCreator(); |
| 146 |
} |
| 147 |
qr_code_creator_init(); |
| 148 |
|
| 149 |
|
| 150 |
|