Skip to content

Welcome: Make it possible to remove steps #1809

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

Merged
merged 4 commits into from
Jun 16, 2025

Conversation

obenland
Copy link
Member

@obenland obenland commented Jun 12, 2025

Makes it possible to remove an onboarding step by removing the action that adds it, and the step tracking still keeping track correctly.

Proposed changes:

  • Adds tests.
  • Makes sure a step is registered before counting it.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • In a snippets plugin, or any other place, remove an onboarding step by removing the action that adds it. For example \remove_action( 'activitypub_onboarding_steps', array( Activitypub\WP_Admin\Welcome_Fields::class, 'render_step_profile_mode' ), 40 );
  • Visit Settings > Activitypub and complete the remaining steps.
  • Make sure the count and next-item highlight work as expected.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Step completion tracking in the Welcome tab now even works when the number of steps gets reduced.

@obenland obenland requested review from Copilot and pfefferle June 12, 2025 19:17
@obenland obenland marked this pull request as ready for review June 12, 2025 19:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Enables dynamic removal of onboarding steps by checking for their existence before counting or selecting them, and adds tests to verify this behavior.

  • Guard step logic in completion and next-step methods with has_step to skip removed steps
  • Introduce has_step helper to detect hooked steps
  • Add unit tests covering removal scenarios for completed, total, and next steps

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/includes/wp-admin/class-test-welcome-fields.php New tests for get_completed_steps_count, get_total_steps_count, and get_next_incomplete_step with step removal scenarios
includes/wp-admin/class-welcome-fields.php Wrapped existing step checks with has_step, and added the has_step helper method
Comments suppressed due to low confidence (1)

tests/includes/wp-admin/class-test-welcome-fields.php:113

  • [nitpick] Method names prefixed with double underscores are typically reserved for PHP magic methods; consider renaming __return_option_zero to something like return_option_zero to avoid confusion.
public function __return_option_zero() { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore

Hooks don't get preserved between tests.
@obenland obenland merged commit 2464f6e into trunk Jun 16, 2025
11 checks passed
@obenland obenland deleted the update/welcome-step-management branch June 16, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants