Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Sell Course with WooCommerce task and deprecate task class #7572

Merged
merged 6 commits into from Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/add-deprecate-sell-course-wth-woocommerce-task
@@ -0,0 +1,4 @@
Significance: minor
Type: deprecated

Remove Sell your course with WooCommerce task from core
Expand Up @@ -67,10 +67,6 @@ private function get_tasks(): array {
new Sensei_Home_Task_Publish_First_Course(),
];

if ( Sensei_Home_Task_Sell_Course_With_WooCommerce::is_active() ) {
$core_tasks[] = new Sensei_Home_Task_Sell_Course_With_WooCommerce();
}

if ( Sensei_Home_Task_Pro_Upsell::is_active() ) {
$core_tasks[] = new Sensei_Home_Task_Pro_Upsell();
}
Expand Down
Expand Up @@ -9,11 +9,24 @@
/**
* 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT of adding a constructor here calling the _deprecated_function. So if something is still using it will add the warning to the logs.

Copy link
Contributor Author

@Imran92 Imran92 Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, updated here 9ac6dca

*
* @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' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!

_deprecated_class( __CLASS__, '$$next-version$$', 'Sensei_Home_Task_Pro_Upsell' );

Check warning on line 24 in includes/admin/home/tasks/task/class-sensei-home-task-sell-course-with-woocommerce.php

View check run for this annotation

Codecov / codecov/patch

includes/admin/home/tasks/task/class-sensei-home-task-sell-course-with-woocommerce.php#L22-L24

Added lines #L22 - L24 were not covered by tests
} else {
_deprecated_function( __METHOD__, '$$next-version$$', 'Sensei_Home_Task_Pro_Upsell::__construct' );

Check warning on line 26 in includes/admin/home/tasks/task/class-sensei-home-task-sell-course-with-woocommerce.php

View check run for this annotation

Codecov / codecov/patch

includes/admin/home/tasks/task/class-sensei-home-task-sell-course-with-woocommerce.php#L26

Added line #L26 was not covered by tests
}
}

/**
* The ID for the task.
*
Expand Down
19 changes: 0 additions & 19 deletions includes/class-sensei-admin.php
Expand Up @@ -55,7 +55,6 @@ public function __construct() {
add_action( 'menu_order', array( $this, 'admin_menu_order' ) );
add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) );
add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_print_scripts', array( $this, 'sensei_set_plugin_url' ) );

// Duplicate lesson & courses
Expand Down Expand Up @@ -1595,24 +1594,6 @@ function( $item ) use ( $type ) {
return $course_structure;
}

/**
* Registers the hook to call mark_completed on tasks that have been
* completed.
*
* @access private
* @return void
*/
public function admin_init() {
global $pagenow;

if ( Sensei_Home_Task_Sell_Course_With_WooCommerce::is_active() ) {
$hook = get_plugin_page_hook( 'wc-admin', 'woocommerce' );
if ( null !== $hook ) {
add_action( $hook, [ Sensei_Home_Task_Sell_Course_With_WooCommerce::class, 'mark_completed' ] );
}
}
}

function sensei_add_custom_menu_items() {
global $pagenow;

Expand Down