| @@ -51,13 +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/register', [ $this, 'register_controls' ], 15 ); | |
| 55 | 56 | add_action( 'elementor/frontend/after_register_scripts', [ $this, 'frontend_register_scripts' ], 10 ); |
| 56 | 57 | add_action( 'elementor/frontend/after_register_styles', [ $this, 'frontend_register_styles' ], 10 ); |
| 57 | 58 | add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_enqueue_styles' ], 10 ); |
| 58 | 59 | add_action( 'elementor/frontend/after_enqueue_scripts', [ $this, 'frontend_enqueue_scripts' ], 10 ); |
| 59 | 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 ); | |
| 60 | 62 | |
| 61 | 63 | spl_autoload_register( [ $this, 'autoload' ] ); |
| 62 | 64 | remove_theme_support( 'wc-product-gallery-lightbox' ); |
| 63 | 65 | } |
| @@ -101,8 +103,9 @@ | ||
| 101 | 103 | 'modules/product-title', |
| 102 | 104 | 'modules/product-description', |
| 103 | 105 | 'modules/product-quantity', |
| 104 | 106 | 'modules/accept-reject-button', |
| 107 | + 'modules/optin', | |
| 105 | 108 | ]; |
| 106 | 109 | // phpcs:enable |
| 107 | 110 | |
| 108 | 111 | foreach ( $modules as $module ) { |
| @@ -135,8 +138,32 @@ | ||
| 135 | 138 | } |
| 136 | 139 | } |
| 137 | 140 | |
| 138 | 141 | /** |
| 142 | + * Register controls with Elementor by sellkit prefix. | |
| 143 | + * | |
| 144 | + * @since 1.5.0 | |
| 145 | + * @access public | |
| 146 | + * | |
| 147 | + * @param object $controls_manager The controls manager. | |
| 148 | + */ | |
| 149 | + public function register_controls( $controls_manager ) { | |
| 150 | + $controls = [ | |
| 151 | + 'file_uploader', | |
| 152 | + ]; | |
| 153 | + | |
| 154 | + // Register controls. | |
| 155 | + foreach ( $controls as $control ) { | |
| 156 | + $class_path = str_replace( '_', '-', $control ); | |
| 157 | + $class_path = "elementor/controls/{$class_path}"; | |
| 158 | + sellkit()->load_files( [ $class_path ] ); | |
| 159 | + | |
| 160 | + $class_name = 'Sellkit_Elementor_Controls_' . $control; | |
| 161 | + $controls_manager->register( new $class_name() ); | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 139 | 166 | * Autoload classes based on namespace. |
| 140 | 167 | * |
| 141 | 168 | * @since 1.1.0 |
| 142 | 169 | * @access public |
| @@ -186,10 +213,24 @@ | ||
| 186 | 213 | * |
| 187 | 214 | * @return array |
| 188 | 215 | */ |
| 189 | 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 | + | |
| 190 | 227 | return [ |
| 191 | 228 | 'nonce' => wp_create_nonce( 'sellkit_elementor' ), |
| 229 | + 'wcNeedShipping' => $needs_shipping, | |
| 230 | + 'url' => [ | |
| 231 | + 'assets' => sellkit()->plugin_url() . 'assets/', | |
| 232 | + ], | |
| 192 | 233 | ]; |
| 193 | 234 | } |
| 194 | 235 | |
| 195 | 236 | /** |
| @@ -208,9 +249,9 @@ | ||
| 208 | 249 | |
| 209 | 250 | wp_register_style( |
| 210 | 251 | 'sellkit-frontend', |
| 211 | 252 | sellkit()->plugin_url() . 'assets/dist/css/frontend' . $rtl . $suffix . '.css', |
| 212 | - [ 'font-awesome' ], | |
| 253 | + [], | |
| 213 | 254 | sellkit()->version() |
| 214 | 255 | ); |
| 215 | 256 | } |
| 216 | 257 | |
| @@ -253,8 +294,23 @@ | ||
| 253 | 294 | 'sellkit-element-icons', |
| 254 | 295 | sellkit()->plugin_url() . 'assets/dist/css/editor' . $suffix . '.css', |
| 255 | 296 | [], |
| 256 | 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 | + ] | |
| 257 | 313 | ); |
| 258 | 314 | } |
| 259 | 315 | } |
| 260 | 316 | |