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

Bootstrap.php in HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce 2.3.1, at includes/Bootstrap.php

233 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 use Carbon\Carbon;
6
7 /**
8 * The file that defines the core plugin class
9 *
10 * A class definition that includes attributes and functions used across both the
11 * public-facing side of the site and the admin area.
12 *
13 * @link http:nabillemsieh.com
14 * @since 1.0.0
15 *
16 * @package Hurrytimer
17 * @subpackage Hurrytimer/includes
18 */
19
20 /**
21 * The core plugin class.
22 *
23 * This is used to define internationalization, admin-specific hooks, and
24 * public-facing site hooks.
25 *
26 * Also maintains the unique identifier of this plugin as well as the current
27 * version of the plugin.
28 *
29 * @since 1.0.0
30 * @package Hurrytimer
31 * @subpackage Hurrytimer/includes
32 * @author Nabil Lemsieh <contact@nabillemsieh.com>
33 */
34 class Bootstrap
35 {
36 /**
37 * The unique identifier of this plugin.
38 *
39 * @since 1.0.0
40 * @access protected
41 * @var string $pluginName The string used to uniquely identify this plugin.
42 */
43 protected $pluginName;
44
45 /**
46 * The current version of the plugin.
47 *
48 * @since 1.0.0
49 * @access protected
50 * @var string $version The current version of the plugin.
51 */
52 protected $version;
53
54 /**
55 * Define the core functionality of the plugin.
56 *
57 * @since 1.0.0
58 */
59 public function __construct()
60 {
61 $this->version = HURRYT_VERSION;
62 $this->pluginName = 'hurrytimer';
63 }
64
65 public function run()
66 {
67 $this->load_macros();
68 $this->setLocale();
69 Installer::get_instance()->upgrade();
70 $this->register_post_type();
71 $this->define_admin_hooks();
72 $this->define_front_hooks();
73 }
74
75 /**
76 * Autoload the required dependencies for this plugin.
77 *
78 * @since 1.0.0
79 * @access private
80 */
81 public function load_macros() {
82 Carbon::macro( 'getBrowserTimestamp', function () {
83 /**
84 * @var Carbon $this
85 */
86 return $this->getTimestamp() * 1000;
87 } );
88 }
89
90 /**
91 * Define the locale for this plugin for internationalization.
92 *
93 * @since 1.0.0
94 * @access private
95 */
96 private function setLocale()
97 {
98
99 add_action(
100 'plugins_loaded',
101 [
102 new I18n(),
103 'load_plugin_textdomain',
104 ]
105 );
106 }
107
108
109 /**
110 * Register all of the hooks related to the admin area functionality
111 * of the plugin.
112 *
113 * @since 1.0.0
114 * @access private
115 */
116 private function define_admin_hooks()
117 {
118 $plugin_admin = new Admin(
119 $this->getPluginName(),
120 $this->getVersion()
121 );
122 add_action( 'admin_menu', [ $plugin_admin, 'menu' ] );
123 add_action( 'admin_init', [ $plugin_admin, 'settingsBox' ] );
124
125 //removeIf(pro)
126 add_filter( 'add_meta_boxes', [ $plugin_admin, 'upgradeBanner' ] );
127 //endRemoveIf(pro)
128 add_action( 'admin_enqueue_scripts', [ $plugin_admin, 'enqueueStyles' ] );
129 add_action( 'admin_enqueue_scripts', [ $plugin_admin, 'enqueueScripts' ] );
130 }
131
132 /**
133 * Register all of the hooks related to the public-facing functionality
134 * of the plugin.
135 *
136 * @since 1.0.0
137 * @access private
138 */
139 private function define_front_hooks()
140 {
141
142 if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
143 return;
144 }
145 // Make sure shortcode is recognized.
146 $this->register_shortcode();
147
148 if ( hurryt_count_active_campaigns() == 0 ) {
149 return;
150 }
151
152 $front = new Frontend(
153 $this->getPluginName(),
154 $this->getVersion()
155 );
156
157 $front->init();
158
159
160 }
161
162 /**
163 * Register shortcode callback.
164 */
165 function register_shortcode()
166 {
167 $shortcode = new CampaignShortcode();
168 $shortcode->init();
169 }
170
171 /**
172 * The name of the plugin used to uniquely identify it within the context of
173 * WordPress and to define internationalization functionality.
174 *
175 * @return string The name of the plugin.
176 * @since 1.0.0
177 */
178 public function getPluginName()
179 {
180 return $this->pluginName;
181 }
182
183 /**
184 * Retrieve the version number of the plugin.
185 *
186 * @return string The version number of the plugin.
187 * @since 1.0.0
188 */
189 public function getVersion()
190 {
191 return $this->version;
192 }
193
194 public function register_post_type()
195 {
196 $args = array(
197 'label' => __( 'All', DOMAIN ),
198 'labels' => array(
199 'name' => __( 'Campaigns', DOMAIN ),
200 'singular_name' => __( 'Campaign', DOMAIN ),
201 'add_new' => __( 'Add Campaign', DOMAIN ),
202 'add_new_item' => __( 'Add Campaign', DOMAIN ),
203 'edit' => __( 'Edit', DOMAIN ),
204 'edit_item' => __( 'Edit Campaign', DOMAIN ),
205 'new_item' => __( 'New Campaign', DOMAIN ),
206 'view' => __( 'View Campaign', DOMAIN ),
207 'view_item' => __( 'View Campaign', DOMAIN ),
208 'search_items' => __( 'Search Campaign', DOMAIN ),
209 'not_found' => __( 'No Campaign', DOMAIN ),
210 'not_found_in_trash' => __(
211 'No Countdown Timer found in trash',
212 DOMAIN
213 ),
214 'parent' => __( 'Parent Campaign', DOMAIN ),
215 'menu_name' => __( 'All Campaigns', DOMAIN ),
216 ),
217 'public' => false,
218 'show_ui' => true,
219 'publicly_queryable' => false,
220 'exclude_from_search' => true,
221 'show_in_menu' => 'hurrytimer',
222 'hierarchical' => false,
223 'show_in_nav_menus' => false,
224 'rewrite' => false,
225 'query_var' => false,
226 'supports' => array( 'title' ),
227 'has_archive' => false,
228 'menu_positon' => 65,
229 );
230 register_post_type( HURRYT_POST_TYPE, $args );
231 }
232 }
233