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

Clean orphaned adstxt post types. #93

Closed
1 task done
peterwilsoncc opened this issue Apr 13, 2022 · 4 comments · Fixed by #138
Closed
1 task done

Clean orphaned adstxt post types. #93

peterwilsoncc opened this issue Apr 13, 2022 · 4 comments · Fixed by #138
Assignees
Labels
help wanted type:enhancement New feature or request.
Milestone

Comments

@peterwilsoncc
Copy link
Contributor

Is your enhancement related to a problem? Please describe.

The options app_adstxt_post and adstxt_post are used to refer to the post ID for the relevant file.

In the event these options are deleted, a new post of the type app-adstxt or adstxt will be created the next time an admin visits the management screen. The unreferenced post will remain as published in the database.

Once a post and the option have become detached, the post should be deleted. There are a number of options:

  • delete the post if the option is deleted or updated
  • upon visiting the settings page, if a new post is created remove any old posts
  • recover orphaned posts -- this is problematic in that the served ads.txt file could contain unexpected data

Designs

No response

Describe alternatives you've considered

preventing the option from being deleted

This is possible by hooking in to an *_option hook.

However, the option is only likely to be altered via /wp-admin/options.php, WP CLI or by modifying the database directly. Blocking deletion of the option to sufficiently advanced users isn't practical and likely to lead to more people hitting the database directly.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@peterwilsoncc peterwilsoncc added the type:enhancement New feature or request. label Apr 13, 2022
@jeffpaul jeffpaul added this to the 1.6.0 milestone Jun 28, 2022
@sksaju sksaju self-assigned this Mar 5, 2023
@sksaju
Copy link
Member

sksaju commented Mar 6, 2023

@peterwilsoncc After reviewing the plugin, I think removing old posts will disable the user to browse Revisions! Any thoughts? Thanks

@peterwilsoncc
Copy link
Contributor Author

Once the options are deleted, the revision history is lost as an ads.txt post is created from scratch, without any revisions.

However, maybe the plugin could look for an orphaned post and use that if the option has been deleted. That would prevent multiple ads.txt post types been created and restore the revisions from the previous version.

@sksaju
Copy link
Member

sksaju commented Mar 7, 2023

Thanks, I'll create a PR, ASAP

@sksaju
Copy link
Member

sksaju commented Apr 2, 2023

Once the options are deleted, the revision history is lost as an ads.txt post is created from scratch, without any revisions.

However, maybe the plugin could look for an orphaned post and use that if the option has been deleted. That would prevent multiple ads.txt post types been created and restore the revisions from the previous version.

@peterwilsoncc I've added an initial commit on this PR #138 to clean orphaned posts and it's working but needs your opinion on triggering the function! currently, I use admin_init hook to trigger the callback function which is not the best option I guess, should we trigger the function on saving adstxt posts? Thanks

Update: I've moved the function into admin.php, so that function can be triggered while visiting the settings page :)

@peterwilsoncc peterwilsoncc modified the milestones: 1.6.0, 1.5.0 Apr 5, 2023
@dkotter dkotter modified the milestones: 1.5.0, 1.4.3 Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted type:enhancement New feature or request.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants