PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / class-init.php

class-init.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/class-init.php

194 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phcps:ignore
2
3 namespace OPTN\Includes;
4
5 use OPTN\Admin\Admin;
6 use OPTN\Frontend\Frontend;
7 use OPTN\Includes\Loader;
8
9 /**
10 * The core plugin class.
11 *
12 * This is used to define internationalization, admin-specific hooks, and
13 * public-facing site hooks.
14 *
15 * Also maintains the unique identifier of this plugin as well as the current
16 * version of the plugin.
17 *
18 * @since 1.0.0
19 * @package optin
20 * @subpackage optin/includes
21 */
22 class Init {
23
24
25 /**
26 * The loader that's responsible for maintaining and registering all hooks that power
27 * the plugin.
28 *
29 * @since 1.0.0
30 * @access protected
31 * @var Loader $loader Maintains and registers all hooks for the plugin.
32 */
33 protected $loader;
34
35 /**
36 * The unique identifier of this plugin.
37 *
38 * @since 1.0.0
39 * @access protected
40 * @var string $plugin_name The string used to uniquely identify this plugin.
41 */
42 protected $plugin_name;
43
44 /**
45 * The current version of the plugin.
46 *
47 * @since 1.0.0
48 * @access protected
49 * @var string $version The current version of the plugin.
50 */
51 protected $version;
52
53 /**
54 * Define the core functionality of the plugin.
55 *
56 * Set the plugin name and the plugin version that can be used throughout the plugin.
57 * Load the dependencies, define the locale, and set the hooks for the admin area and
58 * the public-facing side of the site.
59 *
60 * @since 1.0.0
61 */
62 public function __construct() {
63 $this->version = OPTN_VERSION;
64 $this->plugin_name = 'optin';
65
66 $this->loader = new Loader();
67 $this->set_locale();
68 $this->define_admin_hooks();
69 $this->define_public_hooks();
70
71 new WowShippingPromotion();
72 new WowAddonsPromotion();
73 new WowRevenuePromotion();
74
75 Db::get_instance()->maybe_install();
76 }
77
78 /**
79 * Define the locale for this plugin for internationalization.
80 *
81 * Uses the OPTN_i18n class in order to set the domain and to register the hook
82 * with WordPress.
83 *
84 * @since 1.0.0
85 * @access private
86 */
87 private function set_locale() {
88
89 $plugin_i18n = new I18n();
90
91 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
92 }
93
94 /**
95 * Register all of the hooks related to the admin area functionality
96 * of the plugin.
97 *
98 * @since 1.0.0
99 * @access private
100 */
101 private function define_admin_hooks() {
102
103 $plugin_admin = new Admin( $this->get_plugin_name(), $this->get_version() );
104
105 // Admin customization.
106 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu_page' );
107 $this->loader->add_action( 'admin_head', $plugin_admin, 'admin_head' );
108 $this->loader->add_action( 'admin_footer', $plugin_admin, 'add_dropdown_html' );
109
110 // Register REST routes.
111 $this->loader->add_action( 'rest_api_init', $plugin_admin, 'register_routes' );
112
113 // Admin panel scripts and styles.
114 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
115 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
116 }
117
118 /**
119 * Register all of the hooks related to the public-facing functionality
120 * of the plugin.
121 *
122 * @since 1.0.0
123 * @access private
124 */
125 private function define_public_hooks() {
126
127 $plugin_public = new Frontend( $this->get_plugin_name(), $this->get_version() );
128
129 // REST.
130 $this->loader->add_action( 'rest_api_init', $plugin_public, 'register_routes' );
131
132 // Visitor count.
133 $this->loader->add_action( 'wp', $plugin_public, 'track_visit' );
134
135 // Analytics.
136 $this->loader->add_action( 'wp', $plugin_public, 'assign_user_id' );
137
138 // Conversion content.
139 $this->loader->add_action( 'safe_style_css', $plugin_public, 'add_to_style_allowlist' );
140 $this->loader->add_action( 'safecss_filter_attr_allow_css', $plugin_public, 'allow_style_attrs', 999, 2 );
141 // $this->loader->add_action( 'wp_kses_allowed_html', $plugin_public, 'add_to_tags_allowlist', 10, 2 );
142 $this->loader->add_action( 'wp', $plugin_public, 'generate_optins' );
143 $this->loader->add_action( 'wp_head', $plugin_public, 'preconnect_google_fonts', 0, 0 );
144 $this->loader->add_action( 'wp_footer', $plugin_public, 'add_content', 999, 0 );
145
146 // Sales tracking.
147 $this->loader->add_action( 'edd_complete_purchase', $plugin_public, 'edd_purchase_tracking' );
148 $this->loader->add_action( 'woocommerce_thankyou', $plugin_public, 'woo_purchase_tracking' );
149
150 // Enqueue scripts and styles.
151 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
152 }
153
154 /**
155 * Run the loader to execute all of the hooks with WordPress.
156 *
157 * @since 1.0.0
158 */
159 public function run() {
160 $this->loader->run();
161 }
162
163 /**
164 * The name of the plugin used to uniquely identify it within the context of
165 * WordPress and to define internationalization functionality.
166 *
167 * @return string The name of the plugin.
168 * @since 1.0.0
169 */
170 public function get_plugin_name() {
171 return $this->plugin_name;
172 }
173
174 /**
175 * The reference to the class that orchestrates the hooks with the plugin.
176 *
177 * @return Loader Orchestrates the hooks of the plugin.
178 * @since 1.0.0
179 */
180 public function get_loader() {
181 return $this->loader;
182 }
183
184 /**
185 * Retrieve the version number of the plugin.
186 *
187 * @return string The version number of the plugin.
188 * @since 1.0.0
189 */
190 public function get_version() {
191 return $this->version;
192 }
193 }
194