PluginProbe
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce / 2.2.0
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce v2.2.0
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.0, at includes/Bootstrap.php

224 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
91 }
92
93 /**
94 * Define the locale for this plugin for internationalization.
95 *
96 * @since 1.0.0
97 * @access private
98 */
99 private function setLocale()
100 {
101
102 add_action(
103 'plugins_loaded',
104 [
105 new I18n(),
106 'load_plugin_textdomain',
107 ]
108 );
109 }
110
111 private function maybeUpgrade()
112 {
113 add_action(
114 'plugins_loaded', function () {
115
116 Upgrade::getInstance()->run();
117 }
118 );
119 }
120
121 /**
122 * Register all of the hooks related to the admin area functionality
123 * of the plugin.
124 *
125 * @since 1.0.0
126 * @access private
127 */
128 private function defineAdminHooks()
129 {
130 $plugin_admin = new Admin(
131 $this->getPluginName(),
132 $this->getVersion()
133 );
134 add_action('admin_menu', [$plugin_admin, 'menu']);
135 add_action('admin_init', [$plugin_admin, 'settingsBox']);
136
137 //removeIf(pro)
138 add_filter('add_meta_boxes', [$plugin_admin, 'upgradeBanner']);
139 //endRemoveIf(pro)
140 add_action('admin_enqueue_scripts', [$plugin_admin, 'enqueueStyles']);
141 add_action('admin_enqueue_scripts', [$plugin_admin, 'enqueueScripts']);
142 }
143
144 /**
145 * Register all of the hooks related to the public-facing functionality
146 * of the plugin.
147 *
148 * @since 1.0.0
149 * @access private
150 */
151 private function defineFrontHooks()
152 {
153 $front = new Frontend(
154 $this->getPluginName(),
155 $this->getVersion()
156 );
157
158 add_action('wp_enqueue_scripts', [$front, 'enqueue_styles']);
159 add_action('wp_enqueue_scripts', [$front, 'enqueue_scripts']);
160 }
161
162 /**
163 * The name of the plugin used to uniquely identify it within the context of
164 * WordPress and to define internationalization functionality.
165 *
166 * @since 1.0.0
167 * @return string The name of the plugin.
168 */
169 public function getPluginName()
170 {
171 return $this->pluginName;
172 }
173
174 /**
175 * Retrieve the version number of the plugin.
176 *
177 * @since 1.0.0
178 * @return string The version number of the plugin.
179 */
180 public function getVersion()
181 {
182 return $this->version;
183 }
184
185 public function registerPostType()
186 {
187 $args = array(
188 'label' => __('All', DOMAIN),
189 'labels' => array(
190 'name' => __('Campaigns', DOMAIN),
191 'singular_name' => __('Campaign', DOMAIN),
192 'add_new' => __('Add Campaign', DOMAIN),
193 'add_new_item' => __('Add Campaign', DOMAIN),
194 'edit' => __('Edit', DOMAIN),
195 'edit_item' => __('Edit Campaign', DOMAIN),
196 'new_item' => __('New Campaign', DOMAIN),
197 'view' => __('View Campaign', DOMAIN),
198 'view_item' => __('View Campaign', DOMAIN),
199 'search_items' => __('Search Campaign', DOMAIN),
200 'not_found' => __('No Campaign', DOMAIN),
201 'not_found_in_trash' => __(
202 'No Countdown Timer found in trash',
203 DOMAIN
204 ),
205 'parent' => __('Parent Campaign', DOMAIN),
206 'menu_name' => __('All Campaigns', DOMAIN),
207 ),
208 'public' => false,
209 'show_ui' => true,
210 'publicly_queryable' => false,
211 'exclude_from_search' => true,
212 'show_in_menu' => 'hurrytimer',
213 'hierarchical' => false,
214 'show_in_nav_menus' => false,
215 'rewrite' => false,
216 'query_var' => false,
217 'supports' => array('title'),
218 'has_archive' => false,
219 'menu_positon' => 65,
220 );
221 register_post_type(HURRYT_POST_TYPE, $args);
222 }
223 }
224