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

296 lines 7.5 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 – Unlock and use strategic spots in any WooCommerce Theme
5 * Plugin URI: https://wordpress.org/plugins/hookmeup/
6 * Description: Helps non-developers insert additional content, banners, shortcodes by exploiting key areas in any WooCommerce Theme, without altering the theme's code. Explore and use hidden places in pages like: Shop, Product Page, Cart, Checkout, Login, Register, My account, Thank You Page. Add banners, text, links, call to actions or anything you can think of in strategic spots on your site that you can't normally manipulate. No coding required.
7 * Version: 1.5.8
8 * Author: Get Bowtied
9 * Author URI: https://www.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: 5.0
15 * Tested up to: 6.1.1
16 * WC requires at least: 5.0
17 * WC tested up to: 7.3
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.2.1';
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 if( !get_option( 'hookmeup_done_import', false ) ) {
95 $done_import = $this->import_options();
96 if( $done_import ) {
97 update_option( 'hookmeup_done_import', true );
98 }
99 }
100 } else {
101 add_action( 'admin_notices', array( $this, 'woocommerce_not_installed_warning' ) );
102 }
103 }
104
105 /**
106 * Ensures only one instance of HookMeUp is loaded or can be loaded.
107 *
108 * @since 1.0.0
109 *
110 * @return HookMeUp
111 */
112 public static function instance() {
113 if ( is_null( self::$_instance ) ) {
114 self::$_instance = new self();
115 }
116 return self::$_instance;
117 }
118
119 /**
120 * Imports hooks stored as theme mods into the options WP table
121 *
122 * @since 1.2.1
123 * @return void
124 */
125 private function import_options() {
126 $done_import = true;
127
128 $hooks = new HookMeUp_Hooks();
129 $hooks_list = $hooks->get_all_hooks();
130 foreach( $hooks_list as $hook) {
131 if( get_theme_mod( $hook['section'] . '_preview' ) ) {
132 update_option( 'hookmeup_' . $hook['section'] . '_preview', get_theme_mod( $hook['section'] . '_preview', 'no' ) );
133 if( get_option( 'hookmeup_' . $hook['section'] . '_preview' ) ) {
134 remove_theme_mod( $hook['section'] . '_preview' );
135 } else {
136 $done_import = false;
137 }
138 }
139 if( get_theme_mod( $hook['slug'] . '_editor' ) ) {
140 update_option( 'hookmeup_' . $hook['slug'] . '_editor', get_theme_mod( $hook['slug'] . '_editor', '' ) );
141 if( get_option( 'hookmeup_' . $hook['slug'] . '_editor' ) ) {
142 remove_theme_mod( $hook['slug'] . '_editor' );
143 } else {
144 $done_import = false;
145 }
146 }
147 }
148
149 return $done_import;
150 }
151
152 /**
153 * Include required core files used in admin and on the frontend.
154 *
155 * @since 1.0.0
156 *
157 * @return void
158 */
159 protected function includes() {
160
161 include_once( HMU_DIR . 'includes/customizer/class/class-hmu-editor.php' );
162 include_once( HMU_DIR . 'includes/customizer/class/class-hmu-collapsible.php' );
163 include_once( HMU_DIR . 'includes/customizer/class/class-hmu-toggle.php' );
164 include_once( HMU_DIR . 'includes/customizer/class/class-hmu-info.php' );
165
166 include_once( HMU_DIR . 'includes/class-hmu-loader.php' );
167 include_once( HMU_DIR . 'includes/class-hmu-i18n.php' );
168 include_once( HMU_DIR . 'includes/class-hmu-hooks.php' );
169 include_once( HMU_DIR . 'includes/class-hmu-customizer.php' );
170
171 include_once( HMU_DIR . 'appsero.php' );
172
173 include_once( HMU_DIR . 'public/class-hmu-public.php' );
174 }
175
176 /**
177 * Add hooks.
178 *
179 * @since 1.2
180 *
181 * @return void
182 */
183 protected function add_hooks() {
184 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_customizer_styles' ) );
185 }
186
187 public function enqueue_customizer_styles() {
188
189 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
190
191 wp_enqueue_script( 'hmu-customizer-scripts',
192 plugins_url( 'includes/customizer/assets/js/hmu-go-to-page.js', __FILE__ ),
193 array( 'jquery' ),
194 $this->get_version(),
195 true
196 );
197
198 wp_enqueue_style( 'hmu-customizer-styles',
199 plugins_url( "includes/customizer/assets/css/customizer{$suffix}.css", __FILE__ ),
200 array(),
201 $this->get_version(),
202 false
203 );
204 }
205
206 /**
207 * Define the locale for this plugin for internationalization.
208 *
209 * @since 1.0.0
210 *
211 * @return void
212 */
213 private function set_locale() {
214 $plugin_i18n = new HookMeUp_i18n();
215 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'hookmeup' );
216 }
217
218 /**
219 * Register all of the hooks related to the public-facing functionality of the plugin.
220 *
221 * @since 1.0.0
222 *
223 * @return void
224 */
225 private function define_public_hooks() {
226
227 $plugin_public = new HookMeUp_Public( $this->get_plugin_name(), $this->get_version() );
228 add_action( 'wp_enqueue_scripts', array( $plugin_public, 'enqueue_styles' ) );
229 }
230
231 /**
232 * Register all of the hooks related to the customizer.
233 *
234 * @since 1.2
235 *
236 * @return void
237 */
238 private function define_customizer() {
239
240 $plugin_customizer = new HookMeUp_Customizer();
241 }
242
243 /**
244 * Display warning when WooCommerce not installed or activated
245 *
246 * @since 1.0.0
247 *
248 * @return void
249 */
250 public function woocommerce_not_installed_warning() {
251 ?>
252 <div class="message error woocommerce-admin-notice woocommerce-st-inactive woocommerce-not-configured">
253 <p><?php echo esc_html_e( 'HookMeUp is enabled but not effective. It requires WooCommerce in order to work.', 'hookmeup' ); ?></p>
254 </div>
255 <?php
256 }
257
258 /**
259 * Run the loader to execute all of the hooks with WordPress.
260 *
261 * @since 1.0.0
262 *
263 * @return void
264 */
265 public function run() {
266 $this->loader->run();
267 }
268
269 /**
270 * The reference to the class that orchestrates the hooks with the plugin.
271 */
272 public function get_loader() {
273 return $this->loader;
274 }
275
276 /**
277 * The name of the plugin used to uniquely identify it within the context of
278 * WordPress and to define internationalization functionality.
279 */
280 public function get_plugin_name() {
281 return $this->plugin_name;
282 }
283
284 /**
285 * Retrieve the version number of the plugin.
286 */
287 public function get_version() {
288 return $this->version;
289 }
290
291 }
292
293 endif;
294
295 $hookmeup = new HookMeUp;
296