PluginProbe
HookMeUp for WooCommerce / 1.0
HookMeUp for WooCommerce v1.0
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.0, at hookmeup.php

192 lines 4.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: Hook Me Up – 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.0.0
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: 4.9.6
16 * WC requires at least: 3.3.4
17 * WC tested up to: 3.4.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( 'HMU' ) ) :
37
38 /**
39 * Hook Me Up class.
40 *
41 * @class HMU
42 * @version 1.0.0
43 */
44 final class HMU {
45
46 /**
47 * Maintaining and registering all hooks that power the plugin.
48 *
49 * @access protected
50 */
51 protected $loader;
52
53 /**
54 * The unique identifier of this plugin.
55 *
56 * @var string
57 */
58 protected $plugin_name = "hookmeup";
59
60 /**
61 * The current version of the plugin.
62 *
63 * @var string
64 */
65 protected $version = '1.0.0';
66
67 /**
68 * The single instance of the class.
69 *
70 * @var HMU
71 */
72 protected static $_instance = null;
73
74 /**
75 * HMU constructor
76 */
77 public function __construct() {
78
79 /**
80 * Die if WooCommerce not installed/activated
81 */
82 if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
83 $this->includes();
84 $this->loader = new HMU_Loader();
85 $this->set_locale();
86 $this->define_admin_hooks();
87 $this->define_public_hooks();
88 } else {
89 add_action( 'admin_notices', array( $this, 'woocommerce_not_installed_warning' ) );
90 }
91 }
92
93 /**
94 * Ensures only one instance of HMU is loaded or can be loaded.
95 */
96 public static function instance() {
97 if ( is_null( self::$_instance ) ) {
98 self::$_instance = new self();
99 }
100 return self::$_instance;
101 }
102
103 /**
104 * Include required core files used in admin and on the frontend.
105 */
106 public function includes() {
107
108 require_once( HMU_DIR . 'includes/class-hmu-loader.php' );
109 require_once( HMU_DIR . 'includes/class-hmu-i18n.php' );
110 require_once( HMU_DIR . 'admin/class-hmu-admin.php' );
111 require_once( HMU_DIR . 'public/class-hmu-public.php' );
112 require_once( HMU_DIR . 'includes/class-hmu-hooks.php' );
113 require_once( HMU_DIR . 'includes/functions-hmu-customizer.php' );
114 }
115
116 /**
117 * Define the locale for this plugin for internationalization.
118 */
119 private function set_locale() {
120 $plugin_i18n = new HMU_i18n();
121 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
122 }
123
124 /**
125 * Register all of the hooks related to the admin area functionality of the plugin.
126 */
127 private function define_admin_hooks() {
128
129 $plugin_admin = new HMU_Admin( $this->get_plugin_name(), $this->get_version() );
130
131 add_action( 'admin_enqueue_scripts', array( $plugin_admin, 'enqueue_styles' ) );
132 add_action( 'admin_enqueue_scripts', array( $plugin_admin, 'enqueue_scripts' ) );
133 add_action( 'wp_ajax_get_customize_section_url', array( $plugin_admin, 'get_customize_section_url' ) );
134 }
135
136 /**
137 * Register all of the hooks related to the public-facing functionality of the plugin.
138 */
139 private function define_public_hooks() {
140
141 $plugin_public = new HMU_Public( $this->get_plugin_name(), $this->get_version() );
142
143 add_action( 'wp_enqueue_scripts', array( $plugin_public, 'enqueue_styles' ) );
144 }
145
146 /**
147 * Display warning when WooCommerce not installed or activated
148 */
149 public function woocommerce_not_installed_warning() {
150 ?>
151 <div class="message error woocommerce-admin-notice woocommerce-st-inactive woocommerce-not-configured">
152 <p><?php echo esc_html_e( 'Hook Me Up is enabled but not effective. It requires WooCommerce in order to work.', 'hookmeup' ); ?></p>
153 </div>
154 <?php
155 }
156
157 /**
158 * Run the loader to execute all of the hooks with WordPress.
159 */
160 public function run() {
161 $this->loader->run();
162 }
163
164 /**
165 * The reference to the class that orchestrates the hooks with the plugin.
166 */
167 public function get_loader() {
168 return $this->loader;
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 public function get_plugin_name() {
176 return $this->plugin_name;
177 }
178
179 /**
180 * Retrieve the version number of the plugin.
181 */
182 public function get_version() {
183 return $this->version;
184 }
185
186 }
187
188 endif;
189
190 $hmu = new HMU;
191
192