| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Modal Window |
| 4 |
* Plugin URI: https://wordpress.org/plugin/modal-window/ |
| 5 |
* Description: Create popups. Insert any content. Trigger on anything. |
| 6 |
* Version: 6.3 |
| 7 |
* Author: Wow-Company |
| 8 |
* Author URI: https://wow-estore.com/ |
| 9 |
* License: GPL-2.0+ |
| 10 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 11 |
* Text Domain: modal-window |
| 12 |
* Domain Path: /languages |
| 13 |
* Item ID: 22 |
| 14 |
* Store URI: https://wow-estore.com/ |
| 15 |
* Author Email: hey@wow-company.com |
| 16 |
* Plugin Menu: Modal Window |
| 17 |
* Rating URI: https://wordpress.org/support/plugin/modal-window/reviews/#new-post |
| 18 |
* Support URI: https://wordpress.org/support/plugin/modal-window/ |
| 19 |
* Item URI: https://wow-estore.com/item/wow-modal-windows-pro/ |
| 20 |
* Documentation: https://wow-estore.com/documentations/modal-window-documentation/ |
| 21 |
* Change URI: https://wordpress.org/plugins/modal-window/#developers |
| 22 |
* |
| 23 |
* PHP version 7.4 |
| 24 |
* |
| 25 |
* @category Wordpress_Plugin |
| 26 |
* @package Wow_Plugin |
| 27 |
* @author Dmytro Lobov <hey@wow-company.com>, Wow-Company |
| 28 |
* @copyright 2024 Dmytro Lobov |
| 29 |
* @license GPL-2.0+ |
| 30 |
*/ |
| 31 |
|
| 32 |
namespace ModalWindow; |
| 33 |
|
| 34 |
use ModalWindow\Admin\DBManager; |
| 35 |
use ModalWindow\Update\UpdateDB; |
| 36 |
|
| 37 |
defined( 'ABSPATH' ) || exit; |
| 38 |
|
| 39 |
if ( ! class_exists( 'WOWP_Plugin' ) ) : |
| 40 |
|
| 41 |
final class WOWP_Plugin { |
| 42 |
|
| 43 |
// Plugin slug |
| 44 |
public const SLUG = 'modal-window'; |
| 45 |
|
| 46 |
// Plugin prefix |
| 47 |
public const PREFIX = 'wow_mwp'; |
| 48 |
|
| 49 |
// Plugin Shortcode |
| 50 |
public const SHORTCODE = 'Modal-Window'; |
| 51 |
|
| 52 |
private static $instance; |
| 53 |
|
| 54 |
private WOWP_Admin $admin; |
| 55 |
private Autoloader $autoloader; |
| 56 |
private WOWP_Public $public; |
| 57 |
|
| 58 |
public static function instance(): WOWP_Plugin { |
| 59 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { |
| 60 |
self::$instance = new self; |
| 61 |
|
| 62 |
self::$instance->includes(); |
| 63 |
|
| 64 |
self::$instance->autoloader = new Autoloader( 'ModalWindow' ); |
| 65 |
self::$instance->admin = new WOWP_Admin(); |
| 66 |
self::$instance->public = new WOWP_Public(); |
| 67 |
|
| 68 |
register_activation_hook( __FILE__, [ self::$instance, 'plugin_activate' ] ); |
| 69 |
add_action( 'plugins_loaded', [ self::$instance, 'loaded' ] ); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
return self::$instance; |
| 74 |
} |
| 75 |
|
| 76 |
// Plugin Root File. |
| 77 |
public static function file(): string { |
| 78 |
return __FILE__; |
| 79 |
} |
| 80 |
|
| 81 |
// Plugin Base Name. |
| 82 |
public static function basename(): string { |
| 83 |
return plugin_basename( __FILE__ ); |
| 84 |
} |
| 85 |
|
| 86 |
// Plugin Folder Path. |
| 87 |
public static function dir(): string { |
| 88 |
return plugin_dir_path( __FILE__ ); |
| 89 |
} |
| 90 |
|
| 91 |
// Plugin Folder URL. |
| 92 |
public static function url(): string { |
| 93 |
return plugin_dir_url( __FILE__ ); |
| 94 |
} |
| 95 |
|
| 96 |
// Get Plugin Info |
| 97 |
public static function info( $show = '' ): string { |
| 98 |
$data = [ |
| 99 |
'name' => 'Plugin Name', |
| 100 |
'version' => 'Version', |
| 101 |
'url' => 'Plugin URI', |
| 102 |
'author' => 'Author', |
| 103 |
'email' => 'Author Email', |
| 104 |
'store' => 'Store URI', |
| 105 |
'item_id' => 'Item ID', |
| 106 |
'menu_title' => 'Plugin Menu', |
| 107 |
'rating' => 'Rating URI', |
| 108 |
'support' => 'Support URI', |
| 109 |
'pro' => 'Item URI', |
| 110 |
'docs' => 'Documentation', |
| 111 |
'change' => 'Change URI', |
| 112 |
]; |
| 113 |
$plugin_data = get_file_data( __FILE__, $data, false ); |
| 114 |
|
| 115 |
return $plugin_data[ $show ] ?? ''; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Tags allowed inside the modal content. |
| 120 |
* |
| 121 |
* wp_kses_post() strips form, input, select and option, so the same extended set |
| 122 |
* has to be used both when the content is saved and when it is rendered. |
| 123 |
*/ |
| 124 |
public static function allowed_html(): array { |
| 125 |
return array_merge( |
| 126 |
wp_kses_allowed_html( 'post' ), |
| 127 |
[ |
| 128 |
'form' => [ 'action' => true, 'method' => true, 'id' => true, 'class' => true ], |
| 129 |
'input' => [ |
| 130 |
'type' => true, |
| 131 |
'name' => true, |
| 132 |
'value' => true, |
| 133 |
'placeholder' => true, |
| 134 |
'id' => true, |
| 135 |
'class' => true, |
| 136 |
'checked' => true, |
| 137 |
'required' => true, |
| 138 |
], |
| 139 |
'textarea' => [ |
| 140 |
'name' => true, |
| 141 |
'id' => true, |
| 142 |
'class' => true, |
| 143 |
'rows' => true, |
| 144 |
'cols' => true, |
| 145 |
'placeholder' => true, |
| 146 |
'required' => true, |
| 147 |
], |
| 148 |
'button' => [ 'type' => true, 'name' => true, 'value' => true, 'id' => true, 'class' => true, 'style' => true ], |
| 149 |
'select' => [ 'name' => true, 'id' => true, 'class' => true, 'required' => true ], |
| 150 |
'option' => [ 'value' => true, 'selected' => true ], |
| 151 |
] |
| 152 |
); |
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* Include required files. |
| 157 |
* |
| 158 |
* @access private |
| 159 |
* @since 1.0 |
| 160 |
*/ |
| 161 |
private function includes(): void { |
| 162 |
if ( ! class_exists( 'Wow_Company' ) ) { |
| 163 |
require_once self::dir() . 'includes/class-wow-company.php'; |
| 164 |
} |
| 165 |
|
| 166 |
require_once self::dir() . 'classes/Autoloader.php'; |
| 167 |
require_once self::dir() . 'admin/class-wowp-admin.php'; |
| 168 |
require_once self::dir() . 'public/class-wowp-public.php'; |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Throw error on object clone. |
| 173 |
* The whole idea of the singleton design pattern is that there is a single |
| 174 |
* object therefore, we don't want the object to be cloned. |
| 175 |
* |
| 176 |
* @return void |
| 177 |
* @access protected |
| 178 |
*/ |
| 179 |
public function __clone() { |
| 180 |
// Cloning instances of the class is forbidden. |
| 181 |
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'modal-window' ), '1.0' ); |
| 182 |
} |
| 183 |
|
| 184 |
/** |
| 185 |
* Disable unserializing of the class. |
| 186 |
* |
| 187 |
* @return void |
| 188 |
* @access protected |
| 189 |
*/ |
| 190 |
public function __wakeup() { |
| 191 |
// Unserializing instances of the class is forbidden. |
| 192 |
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'modal-window' ), '1.0' ); |
| 193 |
} |
| 194 |
|
| 195 |
public function plugin_activate(): void { |
| 196 |
|
| 197 |
if ( is_plugin_active( 'wow-modal-windows-pro/wow-modal-windows-pro.php' ) ) { |
| 198 |
deactivate_plugins( 'wow-modal-windows-pro/wow-modal-windows-pro.php' ); |
| 199 |
} |
| 200 |
|
| 201 |
$columns = " |
| 202 |
id mediumint(9) NOT NULL AUTO_INCREMENT, |
| 203 |
title VARCHAR(200), |
| 204 |
param longtext, |
| 205 |
status boolean DEFAULT 0 NOT NULL, |
| 206 |
mode boolean DEFAULT 0 NOT NULL, |
| 207 |
tag text, |
| 208 |
PRIMARY KEY (id) |
| 209 |
"; |
| 210 |
DBManager::create( $columns ); |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Download the folder with languages. |
| 215 |
* |
| 216 |
* @access Publisher |
| 217 |
* @return void |
| 218 |
*/ |
| 219 |
public function loaded(): void { |
| 220 |
UpdateDB::init(); |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
endif; |
| 225 |
|
| 226 |
function wp_plugin_run(): WOWP_Plugin { |
| 227 |
return WOWP_Plugin::instance(); |
| 228 |
} |
| 229 |
|
| 230 |
wp_plugin_run(); |
| 231 |
|
| 232 |
|
| 233 |
|