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