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

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