| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: HookMeUp for WooCommerce |
| 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: 4.3 |
| 8 |
* Author: Get Bowtied |
| 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: 6.0 |
| 15 |
* Tested up to: 7.1 |
| 16 |
* WC requires at least: 10.0 |
| 17 |
* WC tested up to: 11.0.1 |
| 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 |
require_once HMU_DIR . 'core/theme-updater/loader.php'; |
| 39 |
|
| 40 |
/** |
| 41 |
* HookMeUp class. |
| 42 |
* |
| 43 |
* @since 1.0.0.0 |
| 44 |
*/ |
| 45 |
class HookMeUp { |
| 46 |
|
| 47 |
/** |
| 48 |
* Maintaining and registering all hooks that power the plugin. |
| 49 |
* |
| 50 |
* @since 1.0.0 |
| 51 |
* @access protected |
| 52 |
*/ |
| 53 |
protected $loader; |
| 54 |
|
| 55 |
/** |
| 56 |
* The unique identifier of this plugin. |
| 57 |
* |
| 58 |
* @since 1.0.0 |
| 59 |
* @var string |
| 60 |
*/ |
| 61 |
protected $plugin_name = "hookmeup"; |
| 62 |
|
| 63 |
/** |
| 64 |
* The current version of the plugin. |
| 65 |
* |
| 66 |
* @since 1.0.0 |
| 67 |
* @var string |
| 68 |
*/ |
| 69 |
protected $version = '4.3'; |
| 70 |
|
| 71 |
/** |
| 72 |
* The single instance of the class. |
| 73 |
* |
| 74 |
* @since 1.0.0 |
| 75 |
* @var HookMeUp |
| 76 |
*/ |
| 77 |
protected static $_instance = null; |
| 78 |
|
| 79 |
/** |
| 80 |
* HookMeUp constructor |
| 81 |
* |
| 82 |
* @since 1.0.0 |
| 83 |
*/ |
| 84 |
public function __construct() { |
| 85 |
|
| 86 |
/** |
| 87 |
* Die if WooCommerce not installed/activated |
| 88 |
*/ |
| 89 |
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 90 |
$this->includes(); |
| 91 |
$this->add_hooks(); |
| 92 |
$this->loader = new HookMeUp_Loader(); |
| 93 |
$this->set_locale(); |
| 94 |
$this->define_public_hooks(); |
| 95 |
$this->define_customizer(); |
| 96 |
$this->HPOS_compatibility(); |
| 97 |
if( !get_option( 'hookmeup_done_import', false ) ) { |
| 98 |
$done_import = $this->import_options(); |
| 99 |
if( $done_import ) { |
| 100 |
update_option( 'hookmeup_done_import', true ); |
| 101 |
} |
| 102 |
} |
| 103 |
} else { |
| 104 |
add_action( 'admin_notices', array( $this, 'woocommerce_not_installed_warning' ) ); |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Ensures only one instance of HookMeUp is loaded or can be loaded. |
| 110 |
* |
| 111 |
* @since 1.0.0 |
| 112 |
* |
| 113 |
* @return HookMeUp |
| 114 |
*/ |
| 115 |
public static function instance() { |
| 116 |
if ( is_null( self::$_instance ) ) { |
| 117 |
self::$_instance = new self(); |
| 118 |
} |
| 119 |
return self::$_instance; |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Imports hooks stored as theme mods into the options WP table |
| 124 |
* |
| 125 |
* @since 1.2.1 |
| 126 |
* @return void |
| 127 |
*/ |
| 128 |
private function import_options() { |
| 129 |
$done_import = true; |
| 130 |
|
| 131 |
$hooks = new HookMeUp_Hooks(); |
| 132 |
$hooks_list = $hooks->get_all_hooks(); |
| 133 |
foreach( $hooks_list as $hook) { |
| 134 |
if( get_theme_mod( $hook['section'] . '_preview' ) ) { |
| 135 |
update_option( 'hookmeup_' . $hook['section'] . '_preview', get_theme_mod( $hook['section'] . '_preview', 'no' ) ); |
| 136 |
if( get_option( 'hookmeup_' . $hook['section'] . '_preview' ) ) { |
| 137 |
remove_theme_mod( $hook['section'] . '_preview' ); |
| 138 |
} else { |
| 139 |
$done_import = false; |
| 140 |
} |
| 141 |
} |
| 142 |
if( get_theme_mod( $hook['slug'] . '_editor' ) ) { |
| 143 |
update_option( 'hookmeup_' . $hook['slug'] . '_editor', get_theme_mod( $hook['slug'] . '_editor', '' ) ); |
| 144 |
if( get_option( 'hookmeup_' . $hook['slug'] . '_editor' ) ) { |
| 145 |
remove_theme_mod( $hook['slug'] . '_editor' ); |
| 146 |
} else { |
| 147 |
$done_import = false; |
| 148 |
} |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
return $done_import; |
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* Include required core files used in admin and on the frontend. |
| 157 |
* |
| 158 |
* @since 1.0.0 |
| 159 |
* |
| 160 |
* @return void |
| 161 |
*/ |
| 162 |
protected function includes() { |
| 163 |
|
| 164 |
include_once( HMU_DIR . 'includes/customizer/class/class-hmu-editor.php' ); |
| 165 |
include_once( HMU_DIR . 'includes/customizer/class/class-hmu-collapsible.php' ); |
| 166 |
include_once( HMU_DIR . 'includes/customizer/class/class-hmu-toggle.php' ); |
| 167 |
include_once( HMU_DIR . 'includes/customizer/class/class-hmu-info.php' ); |
| 168 |
|
| 169 |
include_once( HMU_DIR . 'includes/class-hmu-loader.php' ); |
| 170 |
include_once( HMU_DIR . 'includes/class-hmu-i18n.php' ); |
| 171 |
include_once( HMU_DIR . 'includes/class-hmu-hooks.php' ); |
| 172 |
include_once( HMU_DIR . 'includes/class-hmu-customizer.php' ); |
| 173 |
|
| 174 |
include_once( HMU_DIR . 'includes/appsero.php' ); |
| 175 |
|
| 176 |
include_once( HMU_DIR . 'public/class-hmu-public.php' ); |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
* Add hooks. |
| 181 |
* |
| 182 |
* @since 1.2 |
| 183 |
* |
| 184 |
* @return void |
| 185 |
*/ |
| 186 |
protected function add_hooks() { |
| 187 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_customizer_styles' ) ); |
| 188 |
} |
| 189 |
|
| 190 |
public function enqueue_customizer_styles() { |
| 191 |
|
| 192 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 193 |
|
| 194 |
wp_enqueue_script( 'hmu-customizer-scripts', |
| 195 |
plugins_url( 'includes/customizer/assets/js/hmu-go-to-page.js', __FILE__ ), |
| 196 |
array( 'jquery' ), |
| 197 |
$this->get_version(), |
| 198 |
true |
| 199 |
); |
| 200 |
|
| 201 |
wp_enqueue_style( 'hmu-customizer-styles', |
| 202 |
plugins_url( "includes/customizer/assets/css/customizer{$suffix}.css", __FILE__ ), |
| 203 |
array(), |
| 204 |
$this->get_version(), |
| 205 |
false |
| 206 |
); |
| 207 |
} |
| 208 |
|
| 209 |
/** |
| 210 |
* Define the locale for this plugin for internationalization. |
| 211 |
* |
| 212 |
* @since 1.0.0 |
| 213 |
* |
| 214 |
* @return void |
| 215 |
*/ |
| 216 |
private function set_locale() { |
| 217 |
$plugin_i18n = new HookMeUp_i18n(); |
| 218 |
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'hookmeup' ); |
| 219 |
} |
| 220 |
|
| 221 |
/** |
| 222 |
* Register all of the hooks related to the public-facing functionality of the plugin. |
| 223 |
* |
| 224 |
* @since 1.0.0 |
| 225 |
* |
| 226 |
* @return void |
| 227 |
*/ |
| 228 |
private function define_public_hooks() { |
| 229 |
|
| 230 |
$plugin_public = new HookMeUp_Public( $this->get_plugin_name(), $this->get_version() ); |
| 231 |
add_action( 'wp_enqueue_scripts', array( $plugin_public, 'enqueue_styles' ) ); |
| 232 |
} |
| 233 |
|
| 234 |
/** |
| 235 |
* Register all of the hooks related to the customizer. |
| 236 |
* |
| 237 |
* @since 1.2 |
| 238 |
* |
| 239 |
* @return void |
| 240 |
*/ |
| 241 |
private function define_customizer() { |
| 242 |
|
| 243 |
$plugin_customizer = new HookMeUp_Customizer(); |
| 244 |
} |
| 245 |
|
| 246 |
/** |
| 247 |
* Register all of the hooks related to the customizer. |
| 248 |
* |
| 249 |
* @since 1.2 |
| 250 |
* |
| 251 |
* @return void |
| 252 |
*/ |
| 253 |
private function HPOS_compatibility() { |
| 254 |
|
| 255 |
add_action('before_woocommerce_init', function(){ |
| 256 |
|
| 257 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 258 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 259 |
|
| 260 |
} |
| 261 |
|
| 262 |
}); |
| 263 |
} |
| 264 |
|
| 265 |
/** |
| 266 |
* Display warning when WooCommerce not installed or activated |
| 267 |
* |
| 268 |
* @since 1.0.0 |
| 269 |
* |
| 270 |
* @return void |
| 271 |
*/ |
| 272 |
public function woocommerce_not_installed_warning() { |
| 273 |
?> |
| 274 |
<div class="message error woocommerce-admin-notice woocommerce-st-inactive woocommerce-not-configured"> |
| 275 |
<p><?php esc_html_e( 'HookMeUp is enabled but not effective. It requires WooCommerce in order to work.', 'hookmeup' ); ?></p> |
| 276 |
</div> |
| 277 |
<?php |
| 278 |
} |
| 279 |
|
| 280 |
/** |
| 281 |
* Run the loader to execute all of the hooks with WordPress. |
| 282 |
* |
| 283 |
* @since 1.0.0 |
| 284 |
* |
| 285 |
* @return void |
| 286 |
*/ |
| 287 |
public function run() { |
| 288 |
$this->loader->run(); |
| 289 |
} |
| 290 |
|
| 291 |
/** |
| 292 |
* The reference to the class that orchestrates the hooks with the plugin. |
| 293 |
*/ |
| 294 |
public function get_loader() { |
| 295 |
return $this->loader; |
| 296 |
} |
| 297 |
|
| 298 |
/** |
| 299 |
* The name of the plugin used to uniquely identify it within the context of |
| 300 |
* WordPress and to define internationalization functionality. |
| 301 |
*/ |
| 302 |
public function get_plugin_name() { |
| 303 |
return $this->plugin_name; |
| 304 |
} |
| 305 |
|
| 306 |
/** |
| 307 |
* Retrieve the version number of the plugin. |
| 308 |
*/ |
| 309 |
public function get_version() { |
| 310 |
return $this->version; |
| 311 |
} |
| 312 |
|
| 313 |
} |
| 314 |
|
| 315 |
endif; |
| 316 |
|
| 317 |
$hookmeup = new HookMeUp; |
| 318 |
|