Skip to content

Require approval for expired listing renewals and reset expiry on publish - #3025

Open
the-sohan wants to merge 3 commits into
sovware:developmentfrom
the-sohan:fix/expired-listing-renewal
Open

the-sohan wants to merge 3 commits into
sovware:developmentfrom
the-sohan:fix/expired-listing-renewal

Conversation

@the-sohan

Copy link
Copy Markdown

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

The dashboard Renew action for an expired listing could lead directly to a checkout URL without a valid checkout_type, displaying “Invalid checkout type.” The core renewal handler also published listings immediately, leaving no opportunity for admin approval.

Renew now uses the authenticated renewal route and submits the listing as Pending Review. A renewal marker identifies listings awaiting approval. When a pending renewal is published, Directorist calculates _expiry_date from the approval time using that listing directory's Default listing expiration days, clears the marker, and fires the renewal completion hook. The owner sees a submission-for-approval notice. The plain-permalink renewal query parameter is also corrected.

Files changed:

  • includes/classes/class-add-listing.php — submit renewals for review and reset expiration when approved.
  • includes/classes/class-permalink.php — correct the listing ID query key for plain permalink renewal URLs.
  • includes/model/ListingDashboard.php — route dashboard Renew through the renewal handler and pass the pending notice state.
  • templates/dashboard/notice.php — show the owner that renewal awaits approval.

How to reproduce the issue or test the changes:

  1. As a listing owner, open an expired listing in Dashboard → My Listings → More → Renew. Before the change, the flow may show “Invalid checkout type” or publish immediately.
  2. With this change, confirm the listing becomes Pending Review and the owner sees “Renewal submitted for approval.” Its old expiration date must not be extended yet.
  3. As an administrator, publish the pending listing. Confirm the new expiration is the approval time plus the listing directory's Default listing expiration days and that a subsequent edit does not renew it again.
  4. Check that an ineligible listing cannot be renewed through the renewal URL.

Local verification:

  • On the local site, the owner's Renew action moved an expired listing to Pending Review while leaving its old expiration unchanged.
  • Publishing that pending listing in wp-admin set expiration seven days from approval, matching the directory default.
  • Rechecked the approval hook with a pending-to-published transition after switching to wp_insert_post; it calculated seven days and cleared the renewal marker. The test listing was restored to its prior expired state.
  • php -l passed for all four changed PHP files; git diff --check origin/development...HEAD passed.

Notes:

  • Paid featured listing and Pricing Plans extension renewal flows were not exercised on the local site.
  • The repository PHPCS executable is unavailable because Composer dependencies are not installed in this worktree.

Any linked issues

Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant