-
Notifications
You must be signed in to change notification settings - Fork 193
/
class-sensei-home-task-sell-course-with-woocommerce.php
101 lines (91 loc) · 2.33 KB
/
class-sensei-home-task-sell-course-with-woocommerce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* File containing the Sensei_Home_Task_Sell_Course_With_WooCommerce class.
*
* @package sensei-lms
* @since 4.8.0
*/
/**
* Sensei_Home_Task_Sell_Course_With_WooCommerce class.
*
* @deprecated $$next-version$$ We're now showing the "Sell your course with Sensei Pro" (Sensei_Home_Task_Pro_Upsell) task instead of this task.
*
* @since 4.8.0
*/
class Sensei_Home_Task_Sell_Course_With_WooCommerce implements Sensei_Home_Task {
const VISITED_WOOCOMMERCE_ADMIN_OPTION_KEY = 'sensei_home_task_visited_woocommerce';
/**
* Class constructor.
*/
public function __construct() {
if ( is_wp_version_compatible( '6.4' ) ) {
_deprecated_class( __CLASS__, '$$next-version$$', 'Sensei_Home_Task_Pro_Upsell' );
} else {
_deprecated_function( __METHOD__, '$$next-version$$', 'Sensei_Home_Task_Pro_Upsell::__construct' );
}
}
/**
* The ID for the task.
*
* @return string
*/
public static function get_id(): string {
return 'sell-course-with-woocommerce';
}
/**
* Number used to sort in frontend.
*
* @return int
*/
public function get_priority(): int {
return 400;
}
/**
* Task title.
*
* @return string
*/
public function get_title(): string {
return __( 'Sell your course with WooCommerce', 'sensei-lms' );
}
/**
* Task url.
*
* @return string
*/
public function get_url(): ?string {
return admin_url( 'admin.php?page=wc-admin' );
}
/**
* Whether the task is completed or not.
*
* @return bool
*/
public function is_completed(): bool {
return (bool) get_option( self::VISITED_WOOCOMMERCE_ADMIN_OPTION_KEY, false );
}
/**
* Mark the task as completed.
*
* @return void
*/
public static function mark_completed() {
update_option( self::VISITED_WOOCOMMERCE_ADMIN_OPTION_KEY, true, false );
sensei_log_event( 'home_task_complete', [ 'type' => self::get_id() ] );
}
/**
* Test if this task should be active or not.
*
* @return bool Whether the task should be active or not.
*/
public static function is_active() {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
return false;
}
$features = Sensei_Setup_Wizard::instance()->get_wizard_user_data( 'features' );
return in_array( 'woocommerce', $features['selected'], true );
}
}