add-to-cart
3 weeks ago
additional-information
3 years ago
advanced-search
1 year ago
archive-description
3 years ago
archive-products
3 weeks ago
archive-result-count
2 years ago
archive-title
1 year ago
archive-view-mode
2 years ago
breadcrumbs
4 years ago
call-for-price
9 months ago
cart-table
3 weeks ago
cart-totals
3 weeks ago
checkout-coupon-form
3 weeks ago
checkout-form-additional
3 years ago
checkout-form-billing
2 years ago
checkout-form-login
3 years ago
checkout-form-shipping
3 weeks ago
checkout-payment
3 years ago
checkout-review-order
2 years ago
checkout-shipping-methods
2 years ago
cross-sells
3 weeks ago
deal-products
2 years ago
empty-cart-message
2 years ago
filter-orderby
2 years ago
filter-products-per-page
3 years ago
filterable-product-list
1 year ago
init
3 weeks ago
notice
2 years ago
product-categories
3 years ago
product-category-lists
1 year ago
product-description
2 years ago
product-excerpt
3 years ago
product-image
1 year ago
product-list
3 weeks ago
product-meta
2 years ago
product-price
3 years ago
product-rating
3 weeks ago
product-review
2 years ago
product-share
2 years ago
product-sku
3 years ago
product-stock
9 months ago
product-tabs
3 weeks ago
product-tags
3 years ago
product-title
2 years ago
qr-code
9 months ago
recently-viewed-products
11 months ago
related
3 weeks ago
return-to-shop
2 years ago
up-sells
3 weeks ago
view-single-product
3 years ago
lazy-cache.php
3 years ago
manifest.php
3 weeks ago
prod-short-code.php
2 years ago
products.php
3 years ago
shop.php
3 years ago
widget-helper.php
2 years ago
manifest.php
322 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Widgets; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Core\Register\Widget_List; |
| 8 | use ShopEngine\Widgets\Init\Enqueue_Scripts; |
| 9 | use ShopEngine\Widgets\Init\Route; |
| 10 | |
| 11 | |
| 12 | class Manifest{ |
| 13 | |
| 14 | private $widget_list; |
| 15 | |
| 16 | public function init() { |
| 17 | |
| 18 | new Enqueue_Scripts(); |
| 19 | new Route(); |
| 20 | |
| 21 | $this->manifest_widgets(); |
| 22 | |
| 23 | add_action('elementor/elements/categories_registered', [$this, 'widget_categories']); |
| 24 | add_action('elementor/widgets/register', [$this, 'register_widgets']); |
| 25 | add_filter('elementor/editor/localize_settings', [$this, 'promote_pro_widgets'], 1000); |
| 26 | add_filter('woocommerce_default_address_fields', function($fields) { |
| 27 | foreach ($fields as $key => $value) { |
| 28 | unset($fields[$key]['priority']); |
| 29 | } |
| 30 | return $fields; |
| 31 | }); |
| 32 | |
| 33 | |
| 34 | // Check if the MP3 Music Player by Sonaar plugin is active |
| 35 | if( ! function_exists('is_plugin_active') ){ |
| 36 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 37 | } |
| 38 | |
| 39 | if(is_plugin_active('mp3-music-player-by-sonaar/sonaar-music.php') || is_plugin_active('smart-wishlist-for-more-convert/smart-wishlist-for-more-convert.php')){ |
| 40 | |
| 41 | add_action('elementor/editor/init', [$this, 'category_initialize'], 0); |
| 42 | |
| 43 | } |
| 44 | |
| 45 | } |
| 46 | |
| 47 | public function category_initialize(){ |
| 48 | $elements_manager = \Elementor\Plugin::instance()->elements_manager; |
| 49 | $this->widget_categories($elements_manager); |
| 50 | } |
| 51 | public function manifest_widgets() { |
| 52 | |
| 53 | foreach(Widget_List::instance()->get_list(true, 'active') as $widget) { |
| 54 | |
| 55 | if(isset($widget['path'])){ |
| 56 | |
| 57 | if(file_exists($widget['path'] . '/' . $widget['slug'] . '-config.php')){ |
| 58 | require_once $widget['path'] . '/' . $widget['slug'] . '-config.php'; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if(class_exists($widget['config_class'])){ |
| 63 | $widget_config = new $widget['config_class'](); |
| 64 | |
| 65 | if($widget_config->custom_inline_css() !== false){ |
| 66 | wp_add_inline_style( 'shopengine-elementor-style', $widget_config->custom_inline_css()); |
| 67 | } |
| 68 | |
| 69 | if($widget_config->custom_inline_js() !== false){ |
| 70 | wp_add_inline_script( 'shopengine-elementor-script', $widget_config->custom_inline_css()); |
| 71 | } |
| 72 | |
| 73 | if($widget_config->custom_init() !== false){ |
| 74 | add_action('init', [$widget_config, 'custom_init']); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | public function register_widgets() { |
| 81 | |
| 82 | foreach(Widget_List::instance()->get_list(true, 'active') as $widget) { |
| 83 | |
| 84 | if(isset($widget['path'])){ |
| 85 | |
| 86 | if(file_exists($widget['path'] . '/' . $widget['slug'] . '.php')){ |
| 87 | require_once $widget['path'] . '/' . $widget['slug'] . '.php'; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | if(isset($widget['base_class']) && class_exists($widget['base_class'])){ |
| 92 | |
| 93 | \Elementor\Plugin::instance()->widgets_manager->register(new $widget['base_class']()); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | /** |
| 98 | * Promote Pro Widgets |
| 99 | * |
| 100 | * @param $settings |
| 101 | * @return void |
| 102 | */ |
| 103 | public function promote_pro_widgets( $settings ) { |
| 104 | if( 'shopengine-template' != get_post_type() || class_exists('\ShopEngine_Pro')) { |
| 105 | return $settings; |
| 106 | } |
| 107 | |
| 108 | if(isset($settings['promotionWidgets']) && is_array($settings['promotionWidgets'])) { |
| 109 | $promotion_widgets = $settings['promotionWidgets']; |
| 110 | } else { |
| 111 | $promotion_widgets = []; |
| 112 | } |
| 113 | |
| 114 | $merged_shopengine_promotion_widgets = array_merge( $promotion_widgets, [ |
| 115 | [ |
| 116 | 'name' => 'account-dashboard', |
| 117 | 'title' => esc_html__( 'Account Dashboard', 'shopengine' ), |
| 118 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_dashboard', |
| 119 | 'categories' => '["shopengine-my_account"]', |
| 120 | ], |
| 121 | [ |
| 122 | 'name' => 'account-address', |
| 123 | 'title' => esc_html__( 'Account Address', 'shopengine' ), |
| 124 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_address', |
| 125 | 'categories' => '["shopengine-my_account"]', |
| 126 | ], |
| 127 | [ |
| 128 | 'name' => 'account-details', |
| 129 | 'title' => esc_html__( 'Account Details', 'shopengine' ), |
| 130 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_form_register', |
| 131 | 'categories' => '["shopengine-my_account"]', |
| 132 | ], |
| 133 | [ |
| 134 | 'name' => 'account-downloads', |
| 135 | 'title' => esc_html__( 'Account Downloads', 'shopengine' ), |
| 136 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_downloads', |
| 137 | 'categories' => '["shopengine-my_account"]', |
| 138 | ], |
| 139 | [ |
| 140 | 'name' => 'account-form-login', |
| 141 | 'title' => esc_html__( 'Account Form Login', 'shopengine' ), |
| 142 | 'icon' => 'shopengine-widget-icon shopengine-icon-checkout_form_login', |
| 143 | 'categories' => '["shopengine-my_account"]', |
| 144 | ], |
| 145 | [ |
| 146 | 'name' => 'account-form-register', |
| 147 | 'title' => esc_html__( 'Account Form Register', 'shopengine' ), |
| 148 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_form_register', |
| 149 | 'categories' => '["shopengine-my_account"]', |
| 150 | ], |
| 151 | [ |
| 152 | 'name' => 'account-logout', |
| 153 | 'title' => esc_html__( 'Account Logout', 'shopengine' ), |
| 154 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_logout', |
| 155 | 'categories' => '["shopengine-my_account"]', |
| 156 | ], |
| 157 | [ |
| 158 | 'name' => 'account-navigation', |
| 159 | 'title' => esc_html__( 'Account Navigation', 'shopengine' ), |
| 160 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_address', |
| 161 | 'categories' => '["shopengine-my_account"]', |
| 162 | ], |
| 163 | [ |
| 164 | 'name' => 'account-order-details', |
| 165 | 'title' => esc_html__( 'Account Order Details', 'shopengine' ), |
| 166 | 'icon' => 'shopengine-widget-icon shopengine-icon-thankyou_order_details', |
| 167 | 'categories' => '["shopengine-my_account"]', |
| 168 | ], |
| 169 | [ |
| 170 | 'name' => 'account-orders', |
| 171 | 'title' => esc_html__( 'Account Orders', 'shopengine' ), |
| 172 | 'icon' => 'shopengine-widget-icon shopengine-icon-orders_ac', |
| 173 | 'categories' => '["shopengine-my_account"]', |
| 174 | ], |
| 175 | [ |
| 176 | 'name' => 'account-wishlist', |
| 177 | 'title' => esc_html__( 'Account Wishlist', 'shopengine' ), |
| 178 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_wishlist', |
| 179 | 'categories' => '["shopengine-my_account"]', |
| 180 | ], |
| 181 | [ |
| 182 | 'name' => 'categories', |
| 183 | 'title' => esc_html__( 'Categories', 'shopengine' ), |
| 184 | 'icon' => 'shopengine-widget-icon shopengine-icon-product_categories', |
| 185 | 'categories' => '["shopengine-general"]', |
| 186 | ], |
| 187 | [ |
| 188 | 'name' => 'product-filters', |
| 189 | 'title' => esc_html__( 'Product Filters', 'shopengine' ), |
| 190 | 'icon' => 'shopengine-widget-icon shopengine-icon-cross_sells', |
| 191 | 'categories' => '["shopengine-archive"]', |
| 192 | ], |
| 193 | [ |
| 194 | 'name' => 'thankyou-address-details', |
| 195 | 'title' => esc_html__( 'Thank You Address Details', 'shopengine' ), |
| 196 | 'icon' => 'shopengine-widget-icon shopengine-icon-thankyou_address_details', |
| 197 | 'categories' => '["shopengine-pro"]', |
| 198 | ], |
| 199 | [ |
| 200 | 'name' => 'thankyou-order-confirm', |
| 201 | 'title' => esc_html__( 'Thank You Order Confirm', 'shopengine' ), |
| 202 | 'icon' => 'shopengine-widget-icon shopengine-icon-thankyou_order_confirm', |
| 203 | 'categories' => '["shopengine-order"]', |
| 204 | ], |
| 205 | [ |
| 206 | 'name' => 'thankyou-order-details', |
| 207 | 'title' => esc_html__( 'Thank You Order Details', 'shopengine' ), |
| 208 | 'icon' => 'shopengine-widget-icon shopengine-icon-thankyou_order_details', |
| 209 | 'categories' => '["shopengine-order"]', |
| 210 | ], |
| 211 | [ |
| 212 | 'name' => 'thankyou-thankyou', |
| 213 | 'title' => esc_html__( 'Order Thank You', 'shopengine' ), |
| 214 | 'icon' => 'shopengine-widget-icon shopengine-icon-thankyou_message', |
| 215 | 'categories' => '["shopengine-order"]', |
| 216 | ], |
| 217 | [ |
| 218 | 'name' => 'currency-switcher', |
| 219 | 'title' => esc_html__( 'Currency Switcher', 'shopengine' ), |
| 220 | 'icon' => 'shopengine-widget-icon shopengine-icon-checkout_payment', |
| 221 | 'categories' => '["shopengine-general"]', |
| 222 | ], |
| 223 | [ |
| 224 | 'name' => 'flash-sale-products', |
| 225 | 'title' => esc_html__( 'Flash Sale Products', 'shopengine' ), |
| 226 | 'icon' => 'shopengine-widget-icon shopengine-icon-archive_products', |
| 227 | 'categories' => '["shopengine-general"]', |
| 228 | ], |
| 229 | [ |
| 230 | 'name' => 'best-selling-product', |
| 231 | 'title' => esc_html__( 'Best Selling Product', 'shopengine' ), |
| 232 | 'icon' => 'shopengine-widget-icon shopengine-icon-orders_ac', |
| 233 | 'categories' => '["shopengine-general"]', |
| 234 | ], |
| 235 | [ |
| 236 | 'name' => 'comparison-button', |
| 237 | 'title' => esc_html__( 'Comparison Button', 'shopengine' ), |
| 238 | 'icon' => 'shopengine-widget-icon shopengine-icon-product_compare_1', |
| 239 | 'categories' => '["shopengine-general"]', |
| 240 | ], |
| 241 | [ |
| 242 | 'name' => 'product-size-charts', |
| 243 | 'title' => esc_html__( 'Product Size Charts', 'shopengine' ), |
| 244 | 'icon' => 'eicon-post-list shopengine-widget-icon', |
| 245 | 'categories' => '["shopengine-single"]', |
| 246 | ], |
| 247 | [ |
| 248 | 'name' => 'vacation', |
| 249 | 'title' => esc_html__( 'Vacation', 'shopengine' ), |
| 250 | 'icon' => 'shopengine-widget-icon shopengine-icon-thankyou_message', |
| 251 | 'categories' => '["shopengine-vacation"]', |
| 252 | ], |
| 253 | [ |
| 254 | 'name' => 'advanced-coupon', |
| 255 | 'title' => esc_html__( 'Advanced Coupon', 'shopengine' ), |
| 256 | 'icon' => 'shopengine-widget-icon shopengine-icon-checkout_coupon_form', |
| 257 | 'categories' => '["shopengine-general"]', |
| 258 | ], |
| 259 | [ |
| 260 | 'name' => 'avatar', |
| 261 | 'title' => esc_html__( 'Avatar', 'shopengine' ), |
| 262 | 'icon' => 'shopengine-widget-icon shopengine-icon-checkout_coupon_form', |
| 263 | 'categories' => '["shopengine-my_account"]', |
| 264 | ], |
| 265 | [ |
| 266 | 'name' => 'account-form-lost-password', |
| 267 | 'title' => esc_html__( 'Lost Password', 'shopengine' ), |
| 268 | 'icon' => 'shopengine-widget-icon shopengine-icon-account_form_register', |
| 269 | 'categories' => '["shopengine-my_account"]', |
| 270 | ], |
| 271 | [ |
| 272 | 'name' => 'checkout-order-pay', |
| 273 | 'title' => esc_html__( 'Checkout Order Pay', 'shopengine' ), |
| 274 | 'icon' => 'shopengine-widget-icon shopengine-icon-cross_sells', |
| 275 | 'categories' => '["shopengine-checkout"]', |
| 276 | ], |
| 277 | [ |
| 278 | 'name' => 'product-carousel', |
| 279 | 'title' => esc_html__( 'Product Carousel', 'shopengine' ), |
| 280 | 'icon' => 'eicon-slider-push shopengine-widget-icon', |
| 281 | 'categories' => '["shopengine-general"]', |
| 282 | ] |
| 283 | ]); |
| 284 | |
| 285 | $settings['promotionWidgets'] = $merged_shopengine_promotion_widgets; |
| 286 | |
| 287 | return $settings; |
| 288 | } |
| 289 | public function widget_categories($elements_manager) { |
| 290 | |
| 291 | $elements_manager->add_category('shopengine-general', [ |
| 292 | 'title' => esc_html__('ShopEngine General', 'shopengine'), |
| 293 | 'icon' => 'fa fa-plug', |
| 294 | ]); |
| 295 | $elements_manager->add_category('shopengine-single', [ |
| 296 | 'title' => esc_html__('ShopEngine Single Product', 'shopengine'), |
| 297 | 'icon' => 'fa fa-plug', |
| 298 | ]); |
| 299 | $elements_manager->add_category('shopengine-cart', [ |
| 300 | 'title' => esc_html__('ShopEngine Cart', 'shopengine'), |
| 301 | 'icon' => 'fa fa-plug', |
| 302 | ]); |
| 303 | $elements_manager->add_category('shopengine-archive', [ |
| 304 | 'title' => esc_html__('ShopEngine Product Archive', 'shopengine'), |
| 305 | 'icon' => 'fa fa-plug', |
| 306 | ]); |
| 307 | $elements_manager->add_category('shopengine-checkout', [ |
| 308 | 'title' => esc_html__('ShopEngine Checkout', 'shopengine'), |
| 309 | 'icon' => 'fa fa-plug', |
| 310 | ]); |
| 311 | $elements_manager->add_category('shopengine-order', [ |
| 312 | 'title' => esc_html__('ShopEngine Order', 'shopengine'), |
| 313 | 'icon' => 'fa fa-plug', |
| 314 | ]); |
| 315 | $elements_manager->add_category('shopengine-my_account', [ |
| 316 | 'title' => esc_html__('ShopEngine My Account', 'shopengine'), |
| 317 | 'icon' => 'fa fa-plug', |
| 318 | ]); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 |