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

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