| @@ -51,14 +51,15 @@ | ||
| 51 | 51 | * @since 1.1.0 |
| 52 | 52 | */ |
| 53 | 53 | public function __construct() { |
| 54 | 54 | add_action( 'elementor/init', [ $this, 'init' ] ); |
| 55 | - add_action( 'elementor/controls/controls_registered', [ $this, 'register_controls' ], 15 ); | |
| 55 | + add_action( 'elementor/controls/register', [ $this, 'register_controls' ], 15 ); | |
| 56 | 56 | add_action( 'elementor/frontend/after_register_scripts', [ $this, 'frontend_register_scripts' ], 10 ); |
| 57 | 57 | add_action( 'elementor/frontend/after_register_styles', [ $this, 'frontend_register_styles' ], 10 ); |
| 58 | 58 | add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_enqueue_styles' ], 10 ); |
| 59 | 59 | add_action( 'elementor/frontend/after_enqueue_scripts', [ $this, 'frontend_enqueue_scripts' ], 10 ); |
| 60 | 60 | add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'editor_enqueue_styles' ], 10 ); |
| 61 | + add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'editor_enqueue_scripts' ], 20 ); | |
| 61 | 62 | |
| 62 | 63 | spl_autoload_register( [ $this, 'autoload' ] ); |
| 63 | 64 | remove_theme_support( 'wc-product-gallery-lightbox' ); |
| 64 | 65 | } |
| @@ -156,9 +157,9 @@ | ||
| 156 | 157 | $class_path = "elementor/controls/{$class_path}"; |
| 157 | 158 | sellkit()->load_files( [ $class_path ] ); |
| 158 | 159 | |
| 159 | 160 | $class_name = 'Sellkit_Elementor_Controls_' . $control; |
| 160 | - $controls_manager->register_control( 'sellkit_' . $control, new $class_name() ); | |
| 161 | + $controls_manager->register( new $class_name() ); | |
| 161 | 162 | } |
| 162 | 163 | } |
| 163 | 164 | |
| 164 | 165 | /** |
| @@ -212,11 +213,24 @@ | ||
| 212 | 213 | * |
| 213 | 214 | * @return array |
| 214 | 215 | */ |
| 215 | 216 | public function get_localize_data() { |
| 217 | + $needs_shipping = ''; | |
| 218 | + | |
| 219 | + if ( function_exists( 'WC' ) ) { | |
| 220 | + $cart = WC()->cart; | |
| 221 | + | |
| 222 | + if ( $cart && method_exists( $cart, 'needs_shipping' ) ) { | |
| 223 | + $needs_shipping = $cart->needs_shipping(); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 216 | 227 | return [ |
| 217 | 228 | 'nonce' => wp_create_nonce( 'sellkit_elementor' ), |
| 218 | - 'wcNeedShipping' => ( function_exists( 'WC' ) ) ? WC()->cart->needs_shipping() : '', | |
| 229 | + 'wcNeedShipping' => $needs_shipping, | |
| 230 | + 'url' => [ | |
| 231 | + 'assets' => sellkit()->plugin_url() . 'assets/', | |
| 232 | + ], | |
| 219 | 233 | ]; |
| 220 | 234 | } |
| 221 | 235 | |
| 222 | 236 | /** |
| @@ -280,8 +294,23 @@ | ||
| 280 | 294 | 'sellkit-element-icons', |
| 281 | 295 | sellkit()->plugin_url() . 'assets/dist/css/editor' . $suffix . '.css', |
| 282 | 296 | [], |
| 283 | 297 | sellkit()->version() |
| 298 | + ); | |
| 299 | + } | |
| 300 | + | |
| 301 | + /** | |
| 302 | + * Enqueue editor scripts. | |
| 303 | + * | |
| 304 | + * @since 1.7.4 | |
| 305 | + */ | |
| 306 | + public function editor_enqueue_scripts() { | |
| 307 | + wp_localize_script( | |
| 308 | + 'sellkit-editor', | |
| 309 | + 'sellkitPromotion', | |
| 310 | + [ | |
| 311 | + 'activeTheme' => wp_get_theme()->get( 'Name' ), | |
| 312 | + ] | |
| 284 | 313 | ); |
| 285 | 314 | } |
| 286 | 315 | } |
| 287 | 316 | |