PluginProbe
HookMeUp for WooCommerce / 1.2
HookMeUp for WooCommerce v1.2
4.3 4.1 trunk 1.0 1.0.1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.5.8 1.6 All 41 releases
hookmeup / hookmeup.php

hookmeup.php in HookMeUp for WooCommerce 1.2, at hookmeup.php

255 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: HookMeUp – Additional Content for WooCommerce
5 * Plugin URI: https://github.com/getbowtied/Hook-Me-Up
6 * Description: Helps you customize WooCommerce templates without altering the code.
7 * Version: 1.2
8 * Author: GetBowtied
9 * Author URI: https://getbowtied.com/
10 * License: GPL-2.0+
11 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
12 * Text Domain: hookmeup
13 * Domain Path: /languages
14 * Requires at least: 4.9
15 * Tested up to: 5.0.1
16 * WC requires at least: 3.3.4
17 * WC tested up to: 3.5.2
18 *
19 * @link getbowtied.com
20 * @since 1.0.0
21 * @package HMU
22 */
23
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit;
26 } // Exit if accessed directly
27
28 if ( ! defined( 'HMU_DIR' ) ) {
29 define( 'HMU_DIR', plugin_dir_path( __FILE__ ) );
30 }
31
32 if ( ! function_exists( 'is_plugin_active' ) ) {
33 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
34 }
35
36 if ( ! class_exists( 'HookMeUp' ) ) :
37
38 /**
39 * HookMeUp class.
40 *
41 * @since 1.0.0.0
42 */
43 class HookMeUp {
44
45 /**
46 * Maintaining and registering all hooks that power the plugin.
47 *
48 * @since 1.0.0
49 * @access protected
50 */
51 protected $loader;
52
53 /**
54 * The unique identifier of this plugin.
55 *
56 * @since 1.0.0
57 * @var string
58 */
59 protected $plugin_name = "hookmeup";
60
61 /**
62 * The current version of the plugin.
63 *
64 * @since 1.0.0
65 * @var string
66 */
67 protected $version = '1.0.0';
68
69 /**
70 * The single instance of the class.
71 *
72 * @since 1.0.0
73 * @var HookMeUp
74 */
75 protected static $_instance = null;
76
77 /**
78 * HookMeUp constructor
79 *
80 * @since 1.0.0
81 */
82 public function __construct() {
83
84 /**
85 * Die if WooCommerce not installed/activated
86 */
87 if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
88 $this->includes();
89 $this->add_hooks();
90 $this->loader = new HookMeUp_Loader();
91 $this->set_locale();
92 $this->define_public_hooks();
93 $this->define_customizer();
94 } else {
95 add_action( 'admin_notices', array( $this, 'woocommerce_not_installed_warning' ) );
96 }
97 }
98
99 /**
100 * Ensures only one instance of HookMeUp is loaded or can be loaded.
101 *
102 * @since 1.0.0
103 *
104 * @return HookMeUp
105 */
106 public static function instance() {
107 if ( is_null( self::$_instance ) ) {
108 self::$_instance = new self();
109 }
110 return self::$_instance;
111 }
112
113 /**
114 * Include required core files used in admin and on the frontend.
115 *
116 * @since 1.0.0
117 *
118 * @return void
119 */
120 protected function includes() {
121
122 include_once( HMU_DIR . 'includes/customizer/class/class-hmu-editor.php' );
123 include_once( HMU_DIR . 'includes/customizer/class/class-hmu-collapsible.php' );
124 include_once( HMU_DIR . 'includes/customizer/class/class-hmu-toggle.php' );
125
126 include_once( HMU_DIR . 'includes/class-hmu-loader.php' );
127 include_once( HMU_DIR . 'includes/class-hmu-i18n.php' );
128 include_once( HMU_DIR . 'includes/class-hmu-hooks.php' );
129 include_once( HMU_DIR . 'includes/class-hmu-customizer.php' );
130
131 include_once( HMU_DIR . 'public/class-hmu-public.php' );
132 }
133
134 /**
135 * Add hooks.
136 *
137 * @since 1.2
138 *
139 * @return void
140 */
141 protected function add_hooks() {
142 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_customizer_styles' ) );
143 }
144
145 public function enqueue_customizer_styles() {
146
147 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
148
149 wp_enqueue_script( 'hmu-customizer-scripts',
150 plugins_url( 'includes/customizer/assets/js/hmu-go-to-page.js', __FILE__ ),
151 array( 'jquery' ),
152 $this->get_version(),
153 true
154 );
155
156 wp_enqueue_style( 'hmu-customizer-styles',
157 plugins_url( "includes/customizer/assets/css/customizer{$suffix}.css", __FILE__ ),
158 array(),
159 $this->get_version(),
160 false
161 );
162 }
163
164 /**
165 * Define the locale for this plugin for internationalization.
166 *
167 * @since 1.0.0
168 *
169 * @return void
170 */
171 private function set_locale() {
172 $plugin_i18n = new HookMeUp_i18n();
173 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'hookmeup' );
174 }
175
176 /**
177 * Register all of the hooks related to the public-facing functionality of the plugin.
178 *
179 * @since 1.0.0
180 *
181 * @return void
182 */
183 private function define_public_hooks() {
184
185 $plugin_public = new HookMeUp_Public( $this->get_plugin_name(), $this->get_version() );
186 add_action( 'wp_enqueue_scripts', array( $plugin_public, 'enqueue_styles' ) );
187 }
188
189 /**
190 * Register all of the hooks related to the customizer.
191 *
192 * @since 1.2
193 *
194 * @return void
195 */
196 private function define_customizer() {
197
198 $plugin_customizer = new HookMeUp_Customizer();
199 }
200
201 /**
202 * Display warning when WooCommerce not installed or activated
203 *
204 * @since 1.0.0
205 *
206 * @return void
207 */
208 public function woocommerce_not_installed_warning() {
209 ?>
210 <div class="message error woocommerce-admin-notice woocommerce-st-inactive woocommerce-not-configured">
211 <p><?php echo esc_html_e( 'HookMeUp is enabled but not effective. It requires WooCommerce in order to work.', 'hookmeup' ); ?></p>
212 </div>
213 <?php
214 }
215
216 /**
217 * Run the loader to execute all of the hooks with WordPress.
218 *
219 * @since 1.0.0
220 *
221 * @return void
222 */
223 public function run() {
224 $this->loader->run();
225 }
226
227 /**
228 * The reference to the class that orchestrates the hooks with the plugin.
229 */
230 public function get_loader() {
231 return $this->loader;
232 }
233
234 /**
235 * The name of the plugin used to uniquely identify it within the context of
236 * WordPress and to define internationalization functionality.
237 */
238 public function get_plugin_name() {
239 return $this->plugin_name;
240 }
241
242 /**
243 * Retrieve the version number of the plugin.
244 */
245 public function get_version() {
246 return $this->version;
247 }
248
249 }
250
251 endif;
252
253 $hookmeup = new HookMeUp;
254
255