PluginProbe
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce / 2.2.8
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce v2.2.8
2.15.0 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 All 62 releases
hurrytimer / includes / Bootstrap.php

Bootstrap.php in HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce 2.2.8, at includes/Bootstrap.php

225 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hurrytimer;
4
5 /**
6 * The file that defines the core plugin class
7 *
8 * A class definition that includes attributes and functions used across both the
9 * public-facing side of the site and the admin area.
10 *
11 * @link http:nabillemsieh.com
12 * @since 1.0.0
13 *
14 * @package Hurrytimer
15 * @subpackage Hurrytimer/includes
16 */
17
18 /**
19 * The core plugin class.
20 *
21 * This is used to define internationalization, admin-specific hooks, and
22 * public-facing site hooks.
23 *
24 * Also maintains the unique identifier of this plugin as well as the current
25 * version of the plugin.
26 *
27 * @since 1.0.0
28 * @package Hurrytimer
29 * @subpackage Hurrytimer/includes
30 * @author Nabil Lemsieh <contact@nabillemsieh.com>
31 */
32 class Bootstrap
33 {
34 /**
35 * The unique identifier of this plugin.
36 *
37 * @since 1.0.0
38 * @access protected
39 * @var string $pluginName The string used to uniquely identify this plugin.
40 */
41 protected $pluginName;
42
43 /**
44 * The current version of the plugin.
45 *
46 * @since 1.0.0
47 * @access protected
48 * @var string $version The current version of the plugin.
49 */
50 protected $version;
51
52 /**
53 * Define the core functionality of the plugin.
54 *
55 * @since 1.0.0
56 */
57 public function __construct()
58 {
59 $this->version = HURRYT_VERSION;
60 $this->pluginName = 'hurrytimer';
61 }
62
63 public function run()
64 {
65 $this->loadDependencies();
66 $this->setLocale();
67 $this->maybeUpgrade();
68 $this->registerPostType();
69 $this->defineAdminHooks();
70 $this->defineFrontHooks();
71 }
72
73 /**
74 * Autoload the required dependencies for this plugin.
75 *
76 * @since 1.0.0
77 * @access private
78 */
79 public function loadDependencies()
80 {
81 require HURRYT_DIR . 'includes/vendor/autoload.php';
82 \spl_autoload_register(function ($class) {
83 if (strpos($class, __NAMESPACE__) !== 0) {
84 return;
85 }
86 $class = str_replace('Hurrytimer', '', $class);
87 $class = str_replace('\\', '/', $class);
88 require_once HURRYT_DIR . "includes/{$class}.php";
89 });
90 require HURRYT_DIR . 'includes/functions.php';
91
92 }
93
94 /**
95 * Define the locale for this plugin for internationalization.
96 *
97 * @since 1.0.0
98 * @access private
99 */
100 private function setLocale()
101 {
102
103 add_action(
104 'plugins_loaded',
105 [
106 new I18n(),
107 'load_plugin_textdomain',
108 ]
109 );
110 }
111
112 private function maybeUpgrade()
113 {
114 add_action(
115 'plugins_loaded', function () {
116
117 Upgrade::getInstance()->run();
118 }
119 );
120 }
121
122 /**
123 * Register all of the hooks related to the admin area functionality
124 * of the plugin.
125 *
126 * @since 1.0.0
127 * @access private
128 */
129 private function defineAdminHooks()
130 {
131 $plugin_admin = new Admin(
132 $this->getPluginName(),
133 $this->getVersion()
134 );
135 add_action('admin_menu', [$plugin_admin, 'menu']);
136 add_action('admin_init', [$plugin_admin, 'settingsBox']);
137
138 //removeIf(pro)
139 add_filter('add_meta_boxes', [$plugin_admin, 'upgradeBanner']);
140 //endRemoveIf(pro)
141 add_action('admin_enqueue_scripts', [$plugin_admin, 'enqueueStyles']);
142 add_action('admin_enqueue_scripts', [$plugin_admin, 'enqueueScripts']);
143 }
144
145 /**
146 * Register all of the hooks related to the public-facing functionality
147 * of the plugin.
148 *
149 * @since 1.0.0
150 * @access private
151 */
152 private function defineFrontHooks()
153 {
154 $front = new Frontend(
155 $this->getPluginName(),
156 $this->getVersion()
157 );
158
159 add_action('wp_enqueue_scripts', [$front, 'enqueue_styles']);
160 add_action('wp_enqueue_scripts', [$front, 'enqueue_scripts']);
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 * @since 1.0.0
168 * @return string The name of the plugin.
169 */
170 public function getPluginName()
171 {
172 return $this->pluginName;
173 }
174
175 /**
176 * Retrieve the version number of the plugin.
177 *
178 * @since 1.0.0
179 * @return string The version number of the plugin.
180 */
181 public function getVersion()
182 {
183 return $this->version;
184 }
185
186 public function registerPostType()
187 {
188 $args = array(
189 'label' => __('All', DOMAIN),
190 'labels' => array(
191 'name' => __('Campaigns', DOMAIN),
192 'singular_name' => __('Campaign', DOMAIN),
193 'add_new' => __('Add Campaign', DOMAIN),
194 'add_new_item' => __('Add Campaign', DOMAIN),
195 'edit' => __('Edit', DOMAIN),
196 'edit_item' => __('Edit Campaign', DOMAIN),
197 'new_item' => __('New Campaign', DOMAIN),
198 'view' => __('View Campaign', DOMAIN),
199 'view_item' => __('View Campaign', DOMAIN),
200 'search_items' => __('Search Campaign', DOMAIN),
201 'not_found' => __('No Campaign', DOMAIN),
202 'not_found_in_trash' => __(
203 'No Countdown Timer found in trash',
204 DOMAIN
205 ),
206 'parent' => __('Parent Campaign', DOMAIN),
207 'menu_name' => __('All Campaigns', DOMAIN),
208 ),
209 'public' => false,
210 'show_ui' => true,
211 'publicly_queryable' => false,
212 'exclude_from_search' => true,
213 'show_in_menu' => 'hurrytimer',
214 'hierarchical' => false,
215 'show_in_nav_menus' => false,
216 'rewrite' => false,
217 'query_var' => false,
218 'supports' => array('title'),
219 'has_archive' => false,
220 'menu_positon' => 65,
221 );
222 register_post_type(HURRYT_POST_TYPE, $args);
223 }
224 }
225