PluginProbe
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce / 1.2.1
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce v1.2.1
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 / class-hurrytimer.php

class-hurrytimer.php in HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce 1.2.1, at includes/class-hurrytimer.php

271 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Hurrytimer;
3
4 /**
5 * The file that defines the core plugin class
6 *
7 * A class definition that includes attributes and functions used across both the
8 * public-facing side of the site and the admin area.
9 *
10 * @link http://nabillemsieh.com
11 * @since 1.0.0
12 *
13 * @package Hurrytimer
14 * @subpackage Hurrytimer/includes
15 */
16
17 /**
18 * The core plugin class.
19 *
20 * This is used to define internationalization, admin-specific hooks, and
21 * public-facing site hooks.
22 *
23 * Also maintains the unique identifier of this plugin as well as the current
24 * version of the plugin.
25 *
26 * @since 1.0.0
27 * @package Hurrytimer
28 * @subpackage Hurrytimer/includes
29 * @author Nabil Lemsieh <contact@nabillemsieh.com>
30 */
31 class Hurrytimer
32 {
33
34 /**
35 * The loader that's responsible for maintaining and registering all hooks that power
36 * the plugin.
37 *
38 * @since 1.0.0
39 * @access protected
40 * @var Hurrytimer_Loader $loader Maintains and registers all hooks for the plugin.
41 */
42 protected $loader;
43
44 /**
45 * The unique identifier of this plugin.
46 *
47 * @since 1.0.0
48 * @access protected
49 * @var string $plugin_name The string used to uniquely identify this plugin.
50 */
51 protected $plugin_name;
52
53 /**
54 * The current version of the plugin.
55 *
56 * @since 1.0.0
57 * @access protected
58 * @var string $version The current version of the plugin.
59 */
60 protected $version;
61
62 /**
63 * Define the core functionality of the plugin.
64 *
65 * Set the plugin name and the plugin version that can be used throughout the plugin.
66 * Load the dependencies, define the locale, and set the hooks for the admin area and
67 * the public-facing side of the site.
68 *
69 * @since 1.0.0
70 */
71 public function __construct()
72 {
73 $this->version = HURRYTIMER_PLUGIN_VERSION;
74 $this->plugin_name = 'hurrytimer';
75 $this->load_dependencies();
76 $this->set_locale();
77 $this->register_post_type();
78 $this->define_admin_hooks();
79 $this->define_public_hooks();
80
81 }
82
83 /**
84 * Load the required dependencies for this plugin.
85 *
86 * Include the following files that make up the plugin:
87 *
88 * - Hurrytimer_Loader. Orchestrates the hooks of the plugin.
89 * - Hurrytimer_i18n. Defines internationalization functionality.
90 * - Hurrytimer_Admin. Defines all hooks for the admin area.
91 * - Hurrytimer_Public. Defines all hooks for the public side of the site.
92 *
93 * Create an instance of the loader which will be used to register the hooks
94 * with WordPress.
95 *
96 * @since 1.0.0
97 * @access private
98 */
99 private function load_dependencies()
100 {
101
102 require_once HURRYTIMER_PLUGIN_DIR . '/includes/utils/class-hurrytimer-constants.php';
103 require_once HURRYTIMER_PLUGIN_DIR . '/includes/utils/class-hurrytimer-helper.php';
104 require_once HURRYTIMER_PLUGIN_DIR . '/includes/utils/class-sql-builder.php';
105 require_once HURRYTIMER_PLUGIN_DIR . '/includes/class-ip-detection.php';
106 require_once HURRYTIMER_PLUGIN_DIR . '/includes/class-cookie-detection.php';
107
108 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-hurrytimer-countdown.php';
109 /**
110 * The class responsible for orchestrating the actions and filters of the
111 * core plugin.
112 */
113 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-hurrytimer-loader.php';
114
115 /**
116 * The class responsible for defining internationalization functionality
117 * of the plugin.
118 */
119 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-hurrytimer-i18n.php';
120
121 /**
122 * The class responsible for defining all actions that occur in the admin area.
123 */
124 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-hurrytimer-admin.php';
125
126 /**
127 * The class responsible for defining all actions that occur in the public-facing
128 * side of the site.
129 */
130 require_once HURRYTIMER_PLUGIN_DIR . '/includes/class-hurrytimer-public.php';
131
132 $this->loader = new Hurrytimer_Loader();
133
134 }
135
136 /**
137 * Define the locale for this plugin for internationalization.
138 *
139 * Uses the Hurrytimer_i18n class in order to set the domain and to register the hook
140 * with WordPress.
141 *
142 * @since 1.0.0
143 * @access private
144 */
145 private function set_locale()
146 {
147
148 $plugin_i18n = new Hurrytimer_i18n();
149
150 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
151
152 }
153
154 /**
155 * Register all of the hooks related to the admin area functionality
156 * of the plugin.
157 *
158 * @since 1.0.0
159 * @access private
160 */
161 private function define_admin_hooks()
162 {
163 $plugin_admin = new Hurrytimer_Admin($this->get_plugin_name(), $this->get_version());
164 $this->loader->add_action('admin_menu', $plugin_admin, 'menu');
165 $this->loader->add_action('admin_init', $plugin_admin, 'meta_boxes');
166 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
167 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
168 }
169
170 /**
171 * Register all of the hooks related to the public-facing functionality
172 * of the plugin.
173 *
174 * @since 1.0.0
175 * @access private
176 */
177 private function define_public_hooks()
178 {
179
180 $plugin_public = new Hurrytimer_Public($this->get_plugin_name(), $this->get_version());
181
182 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
183 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
184
185 }
186
187 /**
188 * Run the loader to execute all of the hooks with WordPress.
189 *
190 * @since 1.0.0
191 */
192 public function run()
193 {
194 $this->loader->run();
195 }
196
197 /**
198 * The name of the plugin used to uniquely identify it within the context of
199 * WordPress and to define internationalization functionality.
200 *
201 * @since 1.0.0
202 * @return string The name of the plugin.
203 */
204 public function get_plugin_name()
205 {
206 return $this->plugin_name;
207 }
208
209 /**
210 * The reference to the class that orchestrates the hooks with the plugin.
211 *
212 * @since 1.0.0
213 * @return Hurrytimer_Loader Orchestrates the hooks of the plugin.
214 */
215 public function get_loader()
216 {
217 return $this->loader;
218 }
219
220 /**
221 * Retrieve the version number of the plugin.
222 *
223 * @since 1.0.0
224 * @return string The version number of the plugin.
225 */
226 public function get_version()
227 {
228 return $this->version;
229 }
230
231 public function register_post_type()
232 {
233 $args = array(
234 'label' => __('All', DOMAIN),
235 'labels' => array(
236 'name' => __('Countdown Timer', DOMAIN),
237 'singular_name' => __('Countdown Timer', DOMAIN),
238 'add_new' => __('Add Timer', DOMAIN),
239 'add_new_item' => __('Add New Timer', DOMAIN),
240 'edit' => __('Edit', DOMAIN),
241 'edit_item' => __('Edit Countdown Timer', DOMAIN),
242 'new_item' => __('New Countdown Timer', DOMAIN),
243 'view' => __('View Countdown Timer', DOMAIN),
244 'view_item' => __('View Countdown Timer', DOMAIN),
245 'search_items' => __('Search Countdown Timer', DOMAIN),
246 'not_found' => __('No Countdown Timer', DOMAIN),
247 'not_found_in_trash' => __('No Countdown Timer found in trash', DOMAIN),
248 'parent' => __('Parent Campaign', DOMAIN),
249 'menu_name' => __('All Timers', DOMAIN),
250 ),
251 'public' => false,
252 'show_ui' => true,
253 'publicly_queryable' => false,
254 'exclude_from_search' => true,
255 'show_in_menu' => 'hurrytimer',
256 'hierarchical' => false,
257 'show_in_nav_menus' => false,
258 'rewrite' => false,
259 'query_var' => false,
260 'supports' => array('title'),
261 'has_archive' => false,
262 'menu_positon' => 65,
263
264 );
265 register_post_type(
266 HURRYTIMER_COUNTDOWN_PT,
267 $args
268 );
269 }
270 }
271