| @@ -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 | - * 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.2.3 | |
| 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: 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. |
| @@ -156,15 +157,26 @@ | ||
| 156 | 157 | public function __construct() { |
| 157 | 158 | $this->define_constants(); |
| 158 | 159 | |
| 159 | 160 | $this->load_files( [ |
| 161 | + 'db', | |
| 160 | 162 | 'functions', |
| 163 | + 'funnel/redirect', | |
| 164 | + 'funnel/homepage', | |
| 161 | 165 | 'funnel/analytics/data-updater', |
| 166 | + 'global-checkout/class', | |
| 162 | 167 | 'funnel/class', |
| 168 | + 'funnel/contacts/base-contacts', | |
| 163 | 169 | 'funnel/steps', |
| 164 | - 'db', | |
| 165 | 170 | ] ); |
| 166 | 171 | |
| 172 | + if ( class_exists( 'SitePress' ) ) { | |
| 173 | + $this->load_files([ | |
| 174 | + 'compatibility/wpml/module', | |
| 175 | + 'compatibility/module', | |
| 176 | + ] ); | |
| 177 | + } | |
| 178 | + | |
| 167 | 179 | $this->db = new Database(); |
| 168 | 180 | |
| 169 | 181 | add_action( 'plugins_loaded', [ $this, 'check_if_has_sellkit_pro' ], 11 ); |
| 170 | 182 | add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); |
| @@ -175,8 +187,10 @@ | ||
| 175 | 187 | |
| 176 | 188 | // Editor script. |
| 177 | 189 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_script' ] ); |
| 178 | 190 | |
| 191 | + add_action( 'requests-curl.before_request', [ $this, 'actions_before_curl_requests' ], 9999 ); | |
| 192 | + | |
| 179 | 193 | // Register activation hook. |
| 180 | 194 | register_activation_hook( __FILE__, array( $this, 'activation' ) ); |
| 181 | 195 | |
| 182 | 196 | if ( ! $this->is_sellkit_screen() ) { |
| @@ -188,15 +202,27 @@ | ||
| 188 | 202 | add_filter( 'admin_body_class', [ $this, 'sellkit_admin_body_class' ] ); |
| 189 | 203 | } |
| 190 | 204 | |
| 191 | 205 | /** |
| 206 | + * Actions before all curl requests. | |
| 207 | + * | |
| 208 | + * @since 1.5.4 | |
| 209 | + * @return void | |
| 210 | + */ | |
| 211 | + public function actions_before_curl_requests() { | |
| 212 | + session_write_close(); | |
| 213 | + } | |
| 214 | + | |
| 215 | + /** | |
| 192 | 216 | * Has sellKit pro. |
| 193 | 217 | * |
| 194 | 218 | * @since 1.1.0 |
| 195 | 219 | */ |
| 196 | 220 | public function check_if_has_sellkit_pro() { |
| 197 | - if ( class_exists( 'Sellkit_Pro' ) ) { | |
| 198 | - $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 | + } | |
| 199 | 225 | } |
| 200 | 226 | } |
| 201 | 227 | |
| 202 | 228 | /** |
| @@ -220,16 +246,25 @@ | ||
| 220 | 246 | * |
| 221 | 247 | * @since 1.1.0 |
| 222 | 248 | */ |
| 223 | 249 | public function plugins_loaded() { |
| 224 | - if ( ! $this->has_valid_dependencies() ) { | |
| 225 | - return false; | |
| 250 | + if ( 'elementor' === $this->page_builder() ) { | |
| 251 | + $this->load_files( [ | |
| 252 | + 'elementor/class', | |
| 253 | + ] ); | |
| 226 | 254 | } |
| 227 | 255 | |
| 228 | 256 | $this->load_files( [ |
| 229 | - 'elementor/class', | |
| 230 | 257 | 'admin/class-promote-sellkit-pro', |
| 258 | + 'admin/class-promotion-banner', | |
| 231 | 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 | + } | |
| 232 | 267 | } |
| 233 | 268 | |
| 234 | 269 | /** |
| 235 | 270 | * Do some stuff on plugin activation. |
| @@ -246,24 +281,36 @@ | ||
| 246 | 281 | |
| 247 | 282 | Install::check_database_tables(); |
| 248 | 283 | |
| 249 | 284 | if ( empty( sellkit_get_option( 'current_db_version' ) ) ) { |
| 250 | - sellkit_update_option( 'current_db_version', '1.2.3' ); // @since 1.2.3 | |
| 285 | + sellkit_update_option( 'current_db_version', '1.2.7' ); // @since 1.5.0 | |
| 251 | 286 | } |
| 252 | 287 | |
| 253 | 288 | if ( ! wp_next_scheduled( 'sellkit_update_rfm_score' ) ) { |
| 254 | 289 | wp_schedule_event( time(), 'twicedaily', 'sellkit_update_rfm_score' ); |
| 255 | 290 | } |
| 291 | + | |
| 292 | + $this->sellkit_installed_time(); | |
| 256 | 293 | } |
| 257 | 294 | |
| 258 | 295 | /** |
| 259 | - * Adding sellkit class to body. | |
| 296 | + * Saves sellkit installation time. | |
| 260 | 297 | * |
| 261 | - * @param string $classes Sellkit the sellkit class. | |
| 298 | + * @since 1.5.9 | |
| 299 | + */ | |
| 300 | + private function sellkit_installed_time() { | |
| 301 | + update_option( 'sellkit-installed-time', time() ); | |
| 302 | + } | |
| 303 | + | |
| 304 | + /** | |
| 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. | |
| 307 | + * | |
| 308 | + * @param string $classes Existing body classes. | |
| 262 | 309 | * @return string |
| 263 | 310 | */ |
| 264 | 311 | public function sellkit_admin_body_class( $classes ) { |
| 265 | - return "{$classes} sellkit"; | |
| 312 | + return "{$classes} sellkit sellkit-admin-screen"; | |
| 266 | 313 | } |
| 267 | 314 | |
| 268 | 315 | /** |
| 269 | 316 | * Initialize admin. |
| @@ -275,12 +322,8 @@ | ||
| 275 | 322 | 'admin/class-notices', |
| 276 | 323 | 'admin/class', |
| 277 | 324 | ] ); |
| 278 | 325 | |
| 279 | - if ( ! $this->has_valid_dependencies() ) { | |
| 280 | - return false; | |
| 281 | - } | |
| 282 | - | |
| 283 | 326 | $this->load_files( [ |
| 284 | 327 | 'admin/utilities', |
| 285 | 328 | 'admin/class-components', |
| 286 | 329 | 'admin/components/class-list-table', |
| @@ -289,8 +332,9 @@ | ||
| 289 | 332 | 'admin/class-posts', |
| 290 | 333 | 'admin/settings/class-settings', |
| 291 | 334 | 'admin/class-custom-tables', |
| 292 | 335 | 'admin/funnel/class', |
| 336 | + 'admin/class-global-checkout', | |
| 293 | 337 | 'core/install', |
| 294 | 338 | ] ); |
| 295 | 339 | } |
| 296 | 340 | |
| @@ -299,12 +343,8 @@ | ||
| 299 | 343 | * |
| 300 | 344 | * @since 1.1.0 |
| 301 | 345 | */ |
| 302 | 346 | public function init() { |
| 303 | - if ( ! $this->has_valid_dependencies() ) { | |
| 304 | - return false; | |
| 305 | - } | |
| 306 | - | |
| 307 | 347 | $this->load_files( [ |
| 308 | 348 | 'admin/class-steps', |
| 309 | 349 | 'utilities/functions', |
| 310 | 350 | 'contact-segmentation/class', |
| @@ -327,9 +367,9 @@ | ||
| 327 | 367 | 'public' => false, |
| 328 | 368 | ] ); |
| 329 | 369 | } |
| 330 | 370 | |
| 331 | - 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. | |
| 332 | 372 | } |
| 333 | 373 | |
| 334 | 374 | /** |
| 335 | 375 | * Enqueue editor scripts. |
| @@ -352,12 +392,8 @@ | ||
| 352 | 392 | * |
| 353 | 393 | * @since 1.1.0 |
| 354 | 394 | */ |
| 355 | 395 | public function enqueue_admin_scripts() { |
| 356 | - if ( ! $this->has_valid_dependencies() ) { | |
| 357 | - return false; | |
| 358 | - } | |
| 359 | - | |
| 360 | 396 | $page = ! empty( $_GET['page'] ) ? $_GET['page'] : ''; // phpcs:ignore |
| 361 | 397 | |
| 362 | 398 | if ( ! in_array( $page, $this->sellkit_menus, true ) ) { |
| 363 | 399 | return false; |
| @@ -386,10 +422,8 @@ | ||
| 386 | 422 | sellkit()->version() |
| 387 | 423 | ); |
| 388 | 424 | |
| 389 | 425 | wp_set_script_translations( 'sellkit', 'sellkit', sellkit()->plugin_dir() . 'languages' ); |
| 390 | - | |
| 391 | - $page = sellkit_htmlspecialchars( INPUT_GET, 'page' ); | |
| 392 | 426 | } |
| 393 | 427 | |
| 394 | 428 | /** |
| 395 | 429 | * Register admin menu. |
| @@ -397,23 +431,30 @@ | ||
| 397 | 431 | * @since 1.1.0 |
| 398 | 432 | * @SuppressWarnings(PHPMD.NPathComplexity) |
| 399 | 433 | */ |
| 400 | 434 | public function register_admin_menu() { |
| 401 | - if ( ! $this->has_valid_dependencies() ) { | |
| 402 | - return false; | |
| 403 | - } | |
| 404 | - | |
| 405 | 435 | $menu_name = esc_html__( 'Sellkit', 'sellkit' ); |
| 406 | 436 | $initial_page = 'sellkit-dashboard'; |
| 407 | 437 | $submenu = [ |
| 408 | 438 | 'sellkit-dashboard' => esc_html__( 'Dashboard', 'sellkit' ), |
| 409 | 439 | 'sellkit-funnel' => esc_html__( 'Funnels', 'sellkit' ), |
| 440 | + 'sellkit-checkout' => esc_html__( 'Global Checkout', 'sellkit' ), | |
| 410 | 441 | ]; |
| 411 | 442 | |
| 412 | 443 | $submenu = apply_filters( 'sellkit_sub_menu', $submenu ); |
| 413 | 444 | |
| 414 | - $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'; | |
| 415 | 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 | + | |
| 416 | 457 | add_menu_page( |
| 417 | 458 | $menu_name, |
| 418 | 459 | $menu_name, |
| 419 | 460 | 'manage_options', |
| @@ -418,9 +459,9 @@ | ||
| 418 | 459 | $menu_name, |
| 419 | 460 | 'manage_options', |
| 420 | 461 | $initial_page, |
| 421 | 462 | [ $this, 'register_admin_menu_callback' ], |
| 422 | - 'data:image/svg+xml;base64,' . base64_encode( wp_remote_retrieve_body( $svg_file ) ), | |
| 463 | + $menu_icon, | |
| 423 | 464 | '58.1' |
| 424 | 465 | ); |
| 425 | 466 | |
| 426 | 467 | foreach ( $submenu as $slug => $title ) { |
| @@ -500,8 +541,9 @@ | ||
| 500 | 541 | 'contactSegmentation' => [ |
| 501 | 542 | 'conditionsOperators' => Operators::$condition_operator_names, |
| 502 | 543 | 'operators' => Operators::$names, |
| 503 | 544 | 'conditionsData' => Conditions::$data, |
| 545 | + 'browserLanguages' => Conditions\Browser_Language::browser_languages_array(), | |
| 504 | 546 | ], |
| 505 | 547 | 'adminUrl' => admin_url(), |
| 506 | 548 | 'url' => site_url(), |
| 507 | 549 | 'timezones' => timezone_identifiers_list(), |
| @@ -511,9 +553,40 @@ | ||
| 511 | 553 | 'elementorActivation' => class_exists( 'Elementor\Plugin' ) ? true : false, |
| 512 | 554 | 'funnelsTemplateSource' => Funnel::SELLKIT_FUNNELS_TEMPLATE_SOURCE, |
| 513 | 555 | 'removedContentBoxes' => Sellkit_Admin_Settings::get_removed_content_box(), |
| 514 | 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 | + : '', | |
| 561 | + 'wcIsActivated' => $this->has_valid_dependencies(), | |
| 562 | + 'activeTheme' => wp_get_theme()->get( 'Name' ), | |
| 563 | + 'pageBuilder' => $this->page_builder(), | |
| 515 | 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; | |
| 516 | 589 | } |
| 517 | 590 | |
| 518 | 591 | /** |
| 519 | 592 | * Get woocommerce settings data. |