| @@ -1,14 +1,14 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin Name: Sellkit | |
| 3 | + * Plugin Name: SellKit - Funnel builder and checkout optimizer for WooCommerce to sell more, faster | |
| 4 | 4 | * Plugin URI: https://getsellkit.com/ |
| 5 | 5 | * Description: Build unlimited sales funnels, one-click order bumps and upsells, custom thank you pages, and more. The free version of SellKit also offers a huge round of features to optimize your WooCommerce store: build and style single or multi-step checkout pages with advanced styling options. Add, remove & reorder form fields. Fasten the form submission process with pre-populated form data, Instant form validation, and removing cart page. All this and more is 100% free and for an unlimited number of sites. |
| 6 | - * Version: 1.6.2 | |
| 6 | + * Version: 2.7.0 | |
| 7 | 7 | * Author: Artbees |
| 8 | 8 | * Author URI: https://artbees.net |
| 9 | 9 | * Text Domain: sellkit |
| 10 | - * License: GPL2 | |
| 10 | + * License: GPLv2 or later | |
| 11 | 11 | * |
| 12 | 12 | * @package Sellkit |
| 13 | 13 | */ |
| 14 | 14 | |
| @@ -122,8 +122,9 @@ | ||
| 122 | 122 | public $sellkit_menus = [ |
| 123 | 123 | 'sellkit-dashboard', |
| 124 | 124 | 'sellkit-funnel', |
| 125 | 125 | 'sellkit-settings', |
| 126 | + 'sellkit-checkout', | |
| 126 | 127 | ]; |
| 127 | 128 | |
| 128 | 129 | /** |
| 129 | 130 | * Has pro plugin or not. |
| @@ -158,14 +159,24 @@ | ||
| 158 | 159 | |
| 159 | 160 | $this->load_files( [ |
| 160 | 161 | 'db', |
| 161 | 162 | 'functions', |
| 163 | + 'funnel/redirect', | |
| 164 | + 'funnel/homepage', | |
| 162 | 165 | 'funnel/analytics/data-updater', |
| 166 | + 'global-checkout/class', | |
| 163 | 167 | 'funnel/class', |
| 164 | 168 | 'funnel/contacts/base-contacts', |
| 165 | 169 | 'funnel/steps', |
| 166 | 170 | ] ); |
| 167 | 171 | |
| 172 | + if ( class_exists( 'SitePress' ) ) { | |
| 173 | + $this->load_files([ | |
| 174 | + 'compatibility/wpml/module', | |
| 175 | + 'compatibility/module', | |
| 176 | + ] ); | |
| 177 | + } | |
| 178 | + | |
| 168 | 179 | $this->db = new Database(); |
| 169 | 180 | |
| 170 | 181 | add_action( 'plugins_loaded', [ $this, 'check_if_has_sellkit_pro' ], 11 ); |
| 171 | 182 | add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); |
| @@ -206,10 +217,12 @@ | ||
| 206 | 217 | * |
| 207 | 218 | * @since 1.1.0 |
| 208 | 219 | */ |
| 209 | 220 | public function check_if_has_sellkit_pro() { |
| 210 | - if ( class_exists( 'Sellkit_Pro' ) ) { | |
| 211 | - $this->has_pro = true; | |
| 221 | + if ( class_exists( 'Sellkit_Pro' ) && function_exists( 'sellkit_pro' ) ) { | |
| 222 | + if ( sellkit_pro()->is_active_sellkit_pro ) { | |
| 223 | + $this->has_pro = true; | |
| 224 | + } | |
| 212 | 225 | } |
| 213 | 226 | } |
| 214 | 227 | |
| 215 | 228 | /** |
| @@ -233,12 +246,25 @@ | ||
| 233 | 246 | * |
| 234 | 247 | * @since 1.1.0 |
| 235 | 248 | */ |
| 236 | 249 | public function plugins_loaded() { |
| 250 | + if ( 'elementor' === $this->page_builder() ) { | |
| 251 | + $this->load_files( [ | |
| 252 | + 'elementor/class', | |
| 253 | + ] ); | |
| 254 | + } | |
| 255 | + | |
| 237 | 256 | $this->load_files( [ |
| 238 | - 'elementor/class', | |
| 239 | 257 | 'admin/class-promote-sellkit-pro', |
| 258 | + 'admin/class-promotion-banner', | |
| 240 | 259 | ] ); |
| 260 | + | |
| 261 | + if ( class_exists( 'WooCommerce' ) && 'gutenberg' === $this->page_builder() ) { | |
| 262 | + $this->load_files( [ | |
| 263 | + 'block-editor/helper', | |
| 264 | + 'block-editor/class', | |
| 265 | + ] ); | |
| 266 | + } | |
| 241 | 267 | } |
| 242 | 268 | |
| 243 | 269 | /** |
| 244 | 270 | * Do some stuff on plugin activation. |
| @@ -275,15 +301,16 @@ | ||
| 275 | 301 | update_option( 'sellkit-installed-time', time() ); |
| 276 | 302 | } |
| 277 | 303 | |
| 278 | 304 | /** |
| 279 | - * Adding sellkit class to body. | |
| 305 | + * Adds `sellkit` on the admin body so `.sellkit …` Bootstrap/Reboot selectors apply. | |
| 306 | + * wp-admin sidebar chrome is toned down in `src/style.scss` where Reboot bleeds through. | |
| 280 | 307 | * |
| 281 | - * @param string $classes Sellkit the sellkit class. | |
| 308 | + * @param string $classes Existing body classes. | |
| 282 | 309 | * @return string |
| 283 | 310 | */ |
| 284 | 311 | public function sellkit_admin_body_class( $classes ) { |
| 285 | - return "{$classes} sellkit"; | |
| 312 | + return "{$classes} sellkit sellkit-admin-screen"; | |
| 286 | 313 | } |
| 287 | 314 | |
| 288 | 315 | /** |
| 289 | 316 | * Initialize admin. |
| @@ -305,8 +332,9 @@ | ||
| 305 | 332 | 'admin/class-posts', |
| 306 | 333 | 'admin/settings/class-settings', |
| 307 | 334 | 'admin/class-custom-tables', |
| 308 | 335 | 'admin/funnel/class', |
| 336 | + 'admin/class-global-checkout', | |
| 309 | 337 | 'core/install', |
| 310 | 338 | ] ); |
| 311 | 339 | } |
| 312 | 340 | |
| @@ -339,9 +367,9 @@ | ||
| 339 | 367 | 'public' => false, |
| 340 | 368 | ] ); |
| 341 | 369 | } |
| 342 | 370 | |
| 343 | - load_plugin_textdomain( 'sellkit', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); | |
| 371 | + // Translations load automatically (WP 4.6+) from wp-content/languages/plugins/ and this plugin's languages directory. | |
| 344 | 372 | } |
| 345 | 373 | |
| 346 | 374 | /** |
| 347 | 375 | * Enqueue editor scripts. |
| @@ -408,14 +436,25 @@ | ||
| 408 | 436 | $initial_page = 'sellkit-dashboard'; |
| 409 | 437 | $submenu = [ |
| 410 | 438 | 'sellkit-dashboard' => esc_html__( 'Dashboard', 'sellkit' ), |
| 411 | 439 | 'sellkit-funnel' => esc_html__( 'Funnels', 'sellkit' ), |
| 440 | + 'sellkit-checkout' => esc_html__( 'Global Checkout', 'sellkit' ), | |
| 412 | 441 | ]; |
| 413 | 442 | |
| 414 | 443 | $submenu = apply_filters( 'sellkit_sub_menu', $submenu ); |
| 415 | 444 | |
| 416 | - $svg_file = wp_remote_get( self::plugin_url() . 'assets/img/icons/sellkit-dashboard.svg' ); | |
| 445 | + // Load SVG from disk. wp_remote_get() to the plugin URL often fails on local/SSL sites and yields an empty icon. | |
| 446 | + $icon_path = sellkit()->plugin_dir() . 'assets/img/icons/sellkit-dashboard.svg'; | |
| 447 | + $menu_icon = 'dashicons-cart'; | |
| 417 | 448 | |
| 449 | + if ( is_readable( $icon_path ) ) { | |
| 450 | + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Reading a bundled asset from the filesystem. | |
| 451 | + $svg_contents = file_get_contents( $icon_path ); | |
| 452 | + if ( false !== $svg_contents && '' !== $svg_contents ) { | |
| 453 | + $menu_icon = 'data:image/svg+xml;base64,' . base64_encode( $svg_contents ); | |
| 454 | + } | |
| 455 | + } | |
| 456 | + | |
| 418 | 457 | add_menu_page( |
| 419 | 458 | $menu_name, |
| 420 | 459 | $menu_name, |
| 421 | 460 | 'manage_options', |
| @@ -420,9 +459,9 @@ | ||
| 420 | 459 | $menu_name, |
| 421 | 460 | 'manage_options', |
| 422 | 461 | $initial_page, |
| 423 | 462 | [ $this, 'register_admin_menu_callback' ], |
| 424 | - 'data:image/svg+xml;base64,' . base64_encode( wp_remote_retrieve_body( $svg_file ) ), | |
| 463 | + $menu_icon, | |
| 425 | 464 | '58.1' |
| 426 | 465 | ); |
| 427 | 466 | |
| 428 | 467 | foreach ( $submenu as $slug => $title ) { |
| @@ -514,10 +553,40 @@ | ||
| 514 | 553 | 'elementorActivation' => class_exists( 'Elementor\Plugin' ) ? true : false, |
| 515 | 554 | 'funnelsTemplateSource' => Funnel::SELLKIT_FUNNELS_TEMPLATE_SOURCE, |
| 516 | 555 | 'removedContentBoxes' => Sellkit_Admin_Settings::get_removed_content_box(), |
| 517 | 556 | 'sellkitProIsActive' => $this->has_pro, |
| 557 | + 'sellkitProPluginInstalled' => class_exists( 'Sellkit_Pro' ) && function_exists( 'sellkit_pro' ), | |
| 558 | + 'sellkitLicensePageUrl' => ( class_exists( 'Sellkit_Pro' ) && function_exists( 'sellkit_pro' ) ) | |
| 559 | + ? ( is_multisite() ? network_admin_url( 'admin.php?page=sellkit-license' ) : admin_url( 'admin.php?page=sellkit-license' ) ) | |
| 560 | + : '', | |
| 518 | 561 | 'wcIsActivated' => $this->has_valid_dependencies(), |
| 562 | + 'activeTheme' => wp_get_theme()->get( 'Name' ), | |
| 563 | + 'pageBuilder' => $this->page_builder(), | |
| 519 | 564 | ]; |
| 565 | + } | |
| 566 | + | |
| 567 | + /** | |
| 568 | + * Get page builder. | |
| 569 | + * | |
| 570 | + * @since 2.3.0 | |
| 571 | + * @return string | |
| 572 | + */ | |
| 573 | + public function page_builder() { | |
| 574 | + $default = 'gutenberg'; | |
| 575 | + | |
| 576 | + if ( class_exists( 'Elementor\Plugin' ) ) { | |
| 577 | + $default = 'elementor'; | |
| 578 | + } | |
| 579 | + | |
| 580 | + $page_builder = sellkit_get_option( 'page_builder', '' ); | |
| 581 | + | |
| 582 | + if ( empty( $page_builder ) ) { | |
| 583 | + sellkit_update_option( 'page_builder', $default ); | |
| 584 | + | |
| 585 | + return $default; | |
| 586 | + } | |
| 587 | + | |
| 588 | + return $page_builder; | |
| 520 | 589 | } |
| 521 | 590 | |
| 522 | 591 | /** |
| 523 | 592 | * Get woocommerce settings data. |