Няма описание

popup-maker.php 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <?php
  2. /**
  3. * Plugin Name: Popup Maker
  4. * Plugin URI: https://wppopupmaker.com/?utm_campaign=plugin-info&utm_source=plugin-header&utm_medium=plugin-uri
  5. * Description: Easily create & style popups with any content. Theme editor to quickly style your popups. Add forms, social media boxes, videos & more.
  6. * Version: 1.16.4
  7. * Author: Popup Maker
  8. * Author URI: https://wppopupmaker.com/?utm_campaign=plugin-info&utm_source=plugin-header&utm_medium=author-uri
  9. * License: GPL2 or later
  10. * License URI: https://www.gnu.org/licenses/gpl-2.0.html
  11. * Text Domain: popup-maker
  12. * Domain Path: /languages/
  13. *
  14. * @package PopupMaker
  15. * @author Daniel Iser
  16. * @copyright Copyright (c) 2021, Code Atlantic LLC
  17. */
  18. // Exit if accessed directly.
  19. if ( ! defined( 'ABSPATH' ) ) {
  20. exit;
  21. }
  22. /**
  23. * Class Autoloader
  24. *
  25. * @param $class
  26. */
  27. function pum_autoloader( $class ) {
  28. if ( strncmp( 'PUM_Newsletter_', $class, strlen( 'PUM_Newsletter_' ) ) === 0 && class_exists( 'PUM_MCI' ) && ! empty( PUM_MCI::$VER ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ) ) {
  29. return;
  30. }
  31. $pum_autoloaders = apply_filters( 'pum_autoloaders', array(
  32. array(
  33. 'prefix' => 'PUM_',
  34. 'dir' => dirname( __FILE__ ) . '/classes/',
  35. ),
  36. ) );
  37. foreach ( $pum_autoloaders as $autoloader ) {
  38. $autoloader = wp_parse_args( $autoloader, array(
  39. 'prefix' => 'PUM_',
  40. 'dir' => dirname( __FILE__ ) . '/classes/',
  41. 'search' => '_',
  42. 'replace' => '/',
  43. ) );
  44. // project-specific namespace prefix
  45. $prefix = $autoloader['prefix'];
  46. // does the class use the namespace prefix?
  47. $len = strlen( $prefix );
  48. if ( strncmp( $prefix, $class, $len ) !== 0 ) {
  49. // no, move to the next registered autoloader
  50. continue;
  51. }
  52. // get the relative class name
  53. $relative_class = substr( $class, $len );
  54. // replace the namespace prefix with the base directory, replace namespace
  55. // separators with directory separators in the relative class name, append
  56. // with .php
  57. $file = $autoloader['dir'] . str_replace( $autoloader['search'], $autoloader['replace'], $relative_class ) . '.php';
  58. // if the file exists, require it
  59. if ( file_exists( $file ) ) {
  60. require_once $file;
  61. }
  62. }
  63. }
  64. if ( ! function_exists( 'spl_autoload_register' ) ) {
  65. include 'includes/compat.php';
  66. }
  67. spl_autoload_register( 'pum_autoloader' ); // Register autoloader
  68. /**
  69. * Main Popup_Maker Class
  70. *
  71. * @since 1.0
  72. */
  73. class Popup_Maker {
  74. /**
  75. * @var string Plugin Name
  76. */
  77. public static $NAME = 'Popup Maker';
  78. /**
  79. * @var string Plugin Version
  80. */
  81. public static $VER = '1.16.4';
  82. /**
  83. * @var int DB Version
  84. */
  85. public static $DB_VER = 8;
  86. /**
  87. * @var string License API URL
  88. */
  89. public static $API_URL = 'https://wppopupmaker.com';
  90. /**
  91. * @var string
  92. */
  93. public static $MIN_PHP_VER = '5.6';
  94. /**
  95. * @var string
  96. */
  97. public static $MIN_WP_VER = '4.9';
  98. /**
  99. * @var string Plugin URL
  100. */
  101. public static $URL;
  102. /**
  103. * @var string Plugin Directory
  104. */
  105. public static $DIR;
  106. /**
  107. * @var string Plugin FILE
  108. */
  109. public static $FILE;
  110. /**
  111. * Used to test if debug_mode is enabled.
  112. *
  113. * @var bool
  114. */
  115. public static $DEBUG_MODE = false;
  116. /**
  117. * @var PUM_Utils_Cron
  118. */
  119. public $cron;
  120. /**
  121. * @var PUM_Repository_Popups
  122. */
  123. public $popups;
  124. /**
  125. * @var PUM_Repository_Themes
  126. */
  127. public $themes;
  128. /**
  129. * @var null|PUM_Model_Popup
  130. */
  131. public $current_popup;
  132. /**
  133. * @var null|PUM_Model_Theme
  134. */
  135. public $current_theme;
  136. /**
  137. * @var Popup_Maker The one true Popup_Maker
  138. */
  139. private static $instance;
  140. /**
  141. * Main instance
  142. *
  143. * @return Popup_Maker
  144. */
  145. public static function instance() {
  146. if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Popup_Maker ) ) {
  147. self::$instance = new Popup_Maker;
  148. self::$instance->setup_constants();
  149. self::$instance->includes();
  150. add_action( 'init', array( self::$instance, 'load_textdomain' ) );
  151. self::$instance->init();
  152. }
  153. return self::$instance;
  154. }
  155. /**
  156. * Setup plugin constants
  157. */
  158. private function setup_constants() {
  159. self::$DIR = plugin_dir_path( __FILE__ );
  160. self::$URL = plugins_url( '/', __FILE__ );
  161. self::$FILE = __FILE__;
  162. if ( isset( $_GET['pum_debug'] ) || PUM_Utils_Options::get( 'debug_mode', false ) ) {
  163. self::$DEBUG_MODE = true;
  164. }
  165. if ( ! defined( 'POPMAKE' ) ) {
  166. define( 'POPMAKE', self::$FILE );
  167. }
  168. if ( ! defined( 'POPMAKE_NAME' ) ) {
  169. define( 'POPMAKE_NAME', self::$NAME );
  170. }
  171. if ( ! defined( 'POPMAKE_SLUG' ) ) {
  172. define( 'POPMAKE_SLUG', trim( dirname( plugin_basename( __FILE__ ) ), '/' ) );
  173. }
  174. if ( ! defined( 'POPMAKE_DIR' ) ) {
  175. define( 'POPMAKE_DIR', self::$DIR );
  176. }
  177. if ( ! defined( 'POPMAKE_URL' ) ) {
  178. define( 'POPMAKE_URL', self::$URL );
  179. }
  180. if ( ! defined( 'POPMAKE_NONCE' ) ) {
  181. define( 'POPMAKE_NONCE', 'popmake_nonce' );
  182. }
  183. if ( ! defined( 'POPMAKE_VERSION' ) ) {
  184. define( 'POPMAKE_VERSION', self::$VER );
  185. }
  186. if ( ! defined( 'POPMAKE_DB_VERSION' ) ) {
  187. define( 'POPMAKE_DB_VERSION', self::$DB_VER );
  188. }
  189. if ( ! defined( 'POPMAKE_API_URL' ) ) {
  190. define( 'POPMAKE_API_URL', self::$API_URL );
  191. }
  192. }
  193. /**
  194. * Include required files
  195. */
  196. private function includes() {
  197. require_once self::$DIR . 'includes/compat.php';
  198. // Initialize global options
  199. PUM_Utils_Options::init();
  200. /** Loads most of our core functions */
  201. require_once self::$DIR . 'includes/functions.php';
  202. /** Deprecated functionality */
  203. require_once self::$DIR . 'includes/functions-backcompat.php';
  204. require_once self::$DIR . 'includes/functions-deprecated.php';
  205. require_once self::$DIR . 'includes/deprecated-classes.php';
  206. require_once self::$DIR . 'includes/deprecated-filters.php';
  207. require_once self::$DIR . 'includes/integrations.php';
  208. // Old Stuff.
  209. require_once self::$DIR . 'includes/defaults.php';
  210. require_once self::$DIR . 'includes/input-options.php';
  211. require_once self::$DIR . 'includes/importer/easy-modal-v2.php';
  212. // Phasing Out
  213. require_once self::$DIR . 'includes/class-popmake-fields.php';
  214. require_once self::$DIR . 'includes/class-popmake-popup-fields.php';
  215. /**
  216. * v1.4 Additions
  217. */
  218. require_once self::$DIR . 'includes/class-pum-fields.php';
  219. require_once self::$DIR . 'includes/class-pum-form.php';
  220. // Modules
  221. require_once self::$DIR . 'includes/modules/menus.php';
  222. require_once self::$DIR . 'includes/modules/admin-bar.php';
  223. require_once self::$DIR . 'includes/modules/reviews.php';
  224. require_once self::$DIR . 'includes/pum-install-functions.php';
  225. }
  226. /**
  227. * Loads the plugin language files
  228. */
  229. public function load_textdomain() {
  230. // Set filter for plugin's languages directory
  231. $lang_dir = apply_filters( 'pum_lang_dir', dirname( plugin_basename( POPMAKE ) ) . '/languages/' );
  232. $lang_dir = apply_filters( 'popmake_languages_directory', $lang_dir );
  233. // Try to load Langpacks first, if they are not available fallback to local files.
  234. if ( ! load_plugin_textdomain( 'popup-maker', false, $lang_dir ) ) {
  235. // Traditional WordPress plugin locale filter
  236. $locale = apply_filters( 'plugin_locale', get_locale(), 'popup-maker' );
  237. $mofile = sprintf( '%1$s-%2$s.mo', 'popup-maker', $locale );
  238. // Setup paths to current locale file
  239. $mofile_local = $lang_dir . $mofile;
  240. $mofile_global = WP_LANG_DIR . '/popup-maker/' . $mofile;
  241. if ( file_exists( $mofile_global ) ) {
  242. // Look in global /wp-content/languages/popup-maker folder
  243. load_textdomain( 'popup-maker', $mofile_global );
  244. } elseif ( file_exists( $mofile_local ) ) {
  245. // Look in local /wp-content/plugins/popup-maker/languages/ folder
  246. load_textdomain( 'popup-maker', $mofile_local );
  247. }
  248. }
  249. }
  250. public function init() {
  251. $this->cron = new PUM_Utils_Cron;
  252. $this->popups = new PUM_Repository_Popups();
  253. $this->themes = new PUM_Repository_Themes();
  254. PUM_Types::init();
  255. PUM_AssetCache::init();
  256. PUM_Site::init();
  257. PUM_Admin::init();
  258. PUM_Utils_Upgrades::instance();
  259. PUM_Newsletters::init();
  260. PUM_Previews::init();
  261. PUM_Integrations::init();
  262. PUM_Privacy::init();
  263. PUM_Utils_Alerts::init();
  264. PUM_Shortcode_Popup::init();
  265. PUM_Shortcode_PopupTrigger::init();
  266. PUM_Shortcode_PopupClose::init();
  267. PUM_Shortcode_PopupCookie::init();
  268. PUM_Telemetry::init();
  269. }
  270. /**
  271. * Returns true when debug mode is enabled.
  272. *
  273. * @return bool
  274. */
  275. public static function debug_mode() {
  276. return true === self::$DEBUG_MODE;
  277. }
  278. }
  279. /**
  280. * The main function responsible for returning the one true Popup_Maker
  281. * Instance to functions everywhere.
  282. *
  283. * Use this function like you would a global variable, except without needing
  284. * to declare the global.
  285. *
  286. * @return Popup_Maker
  287. * @since 1.8.0
  288. *
  289. */
  290. function pum() {
  291. return Popup_Maker::instance();
  292. }
  293. /**
  294. * Initialize Popup Maker if requirements are met.
  295. */
  296. function pum_init() {
  297. // TODO Replace this with PUM_Utils_Prerequisites.
  298. if ( ! PUM_Install::meets_activation_requirements() ) {
  299. require_once 'includes/failsafes.php';
  300. add_action( 'admin_notices', array( 'PUM_Install', 'activation_failure_admin_notice' ) );
  301. return;
  302. }
  303. // Get Popup Maker
  304. pum();
  305. add_action( 'plugins_loaded', 'popmake_initialize' );
  306. }
  307. // Get Popup Maker running
  308. add_action( 'plugins_loaded', 'pum_init', 9 );
  309. // Ensure plugin & environment compatibility.
  310. register_activation_hook( __FILE__, array( 'PUM_Install', 'activation_check' ) );
  311. // Register activation, deactivation & uninstall hooks.
  312. register_activation_hook( __FILE__, array( 'PUM_Install', 'activate_plugin' ) );
  313. register_deactivation_hook( __FILE__, array( 'PUM_Install', 'deactivate_plugin' ) );
  314. register_uninstall_hook( __FILE__, array( 'PUM_Install', 'uninstall_plugin' ) );
  315. /**
  316. * @deprecated 1.7.0
  317. */
  318. function popmake_initialize() {
  319. // Disable Unlimited Themes extension if active.
  320. remove_action( 'popmake_initialize', 'popmake_ut_initialize' );
  321. // Initialize old PUM extensions
  322. do_action( 'pum_initialize' );
  323. do_action( 'popmake_initialize' );
  324. }
  325. /**
  326. * The main function responsible for returning the one true Popup_Maker
  327. * Instance to functions everywhere.
  328. *
  329. * Use this function like you would a global variable, except without needing
  330. * to declare the global.
  331. *
  332. * Example: <?php $popmake = PopMake(); ?>
  333. *
  334. * @return object The one true Popup_Maker Instance
  335. * @deprecated 1.7.0
  336. *
  337. * @since 1.0
  338. */
  339. function PopMake() {
  340. return Popup_Maker::instance();
  341. }