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

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

264 lines 7.9 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 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-hurrytimer-countdown.php';
102 /**
103 * The class responsible for orchestrating the actions and filters of the
104 * core plugin.
105 */
106 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-hurrytimer-loader.php';
107
108 /**
109 * The class responsible for defining internationalization functionality
110 * of the plugin.
111 */
112 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-hurrytimer-i18n.php';
113
114 /**
115 * The class responsible for defining all actions that occur in the admin area.
116 */
117 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-hurrytimer-admin.php';
118
119 /**
120 * The class responsible for defining all actions that occur in the public-facing
121 * side of the site.
122 */
123 require_once HURRYTIMER_PLUGIN_DIR . '/includes/class-hurrytimer-public.php';
124
125 $this->loader = new Hurrytimer_Loader();
126
127 }
128
129 /**
130 * Define the locale for this plugin for internationalization.
131 *
132 * Uses the Hurrytimer_i18n class in order to set the domain and to register the hook
133 * with WordPress.
134 *
135 * @since 1.0.0
136 * @access private
137 */
138 private function set_locale()
139 {
140
141 $plugin_i18n = new Hurrytimer_i18n();
142
143 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
144
145 }
146
147 /**
148 * Register all of the hooks related to the admin area functionality
149 * of the plugin.
150 *
151 * @since 1.0.0
152 * @access private
153 */
154 private function define_admin_hooks()
155 {
156 $plugin_admin = new Hurrytimer_Admin($this->get_plugin_name(), $this->get_version());
157 $this->loader->add_action('admin_menu', $plugin_admin, 'menu');
158 $this->loader->add_action('admin_init', $plugin_admin, 'meta_boxes');
159 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
160 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
161 }
162
163 /**
164 * Register all of the hooks related to the public-facing functionality
165 * of the plugin.
166 *
167 * @since 1.0.0
168 * @access private
169 */
170 private function define_public_hooks()
171 {
172
173 $plugin_public = new Hurrytimer_Public($this->get_plugin_name(), $this->get_version());
174
175 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
176 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
177
178 }
179
180 /**
181 * Run the loader to execute all of the hooks with WordPress.
182 *
183 * @since 1.0.0
184 */
185 public function run()
186 {
187 $this->loader->run();
188 }
189
190 /**
191 * The name of the plugin used to uniquely identify it within the context of
192 * WordPress and to define internationalization functionality.
193 *
194 * @since 1.0.0
195 * @return string The name of the plugin.
196 */
197 public function get_plugin_name()
198 {
199 return $this->plugin_name;
200 }
201
202 /**
203 * The reference to the class that orchestrates the hooks with the plugin.
204 *
205 * @since 1.0.0
206 * @return Hurrytimer_Loader Orchestrates the hooks of the plugin.
207 */
208 public function get_loader()
209 {
210 return $this->loader;
211 }
212
213 /**
214 * Retrieve the version number of the plugin.
215 *
216 * @since 1.0.0
217 * @return string The version number of the plugin.
218 */
219 public function get_version()
220 {
221 return $this->version;
222 }
223
224 public function register_post_type()
225 {
226 $args = array(
227 'label' => __('All', DOMAIN),
228 'labels' => array(
229 'name' => __('Countdown Timer', DOMAIN),
230 'singular_name' => __('Countdown Timer', DOMAIN),
231 'add_new' => __('Add Timer', DOMAIN),
232 'add_new_item' => __('Add New Timer', DOMAIN),
233 'edit' => __('Edit', DOMAIN),
234 'edit_item' => __('Edit Countdown Timer', DOMAIN),
235 'new_item' => __('New Countdown Timer', DOMAIN),
236 'view' => __('View Countdown Timer', DOMAIN),
237 'view_item' => __('View Countdown Timer', DOMAIN),
238 'search_items' => __('Search Countdown Timer', DOMAIN),
239 'not_found' => __('No Countdown Timer', DOMAIN),
240 'not_found_in_trash' => __('No Countdown Timer found in trash', DOMAIN),
241 'parent' => __('Parent Campaign', DOMAIN),
242 'menu_name' => __('All Timers', DOMAIN),
243 ),
244 'public' => false,
245 'show_ui' => true,
246 'publicly_queryable' => false,
247 'exclude_from_search' => true,
248 'show_in_menu' => 'hurrytimer',
249 'hierarchical' => false,
250 'show_in_nav_menus' => false,
251 'rewrite' => false,
252 'query_var' => false,
253 'supports' => array('title'),
254 'has_archive' => false,
255 'menu_positon' => 65,
256
257 );
258 register_post_type(
259 HURRYTIMER_COUNTDOWN_PT,
260 $args
261 );
262 }
263 }
264