OnChangeDetection
in package
Uses
UtilsProvider
Automatically detect changes to pages and posts, or CPT's and scan them again.
Table of Contents
Constants
- SKIP_POST_TYPE = []
- In some cases it does not make sense to scan viewable post types as they act e.g. as "template" posts which are reused in publicly available posts and pages.
- USE_PREVIEW_LINK_FOR_POST_TYPE = [ // [Plugin Comp] https://wordpress.org/plugins/coming-soon/ 'seedprod', ]
- In some cases, custom post types are used in "Draft"-always state or private, so let's use the preview URL (`?preview=true`) instead of the permalink URL.
Properties
- $scanner : mixed
Methods
- __construct() : mixed
- C'tor.
- delete_post() : mixed
- A post got deleted. Remove the URL from the scan results.
- getPluginConstantPrefix() : string
- Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
- post_updated() : mixed
- The `post_updated` hook is fired before `save_post` so we can identify if the slug has been changed (parent or slug).
- save_post() : mixed
- A post got updated or created, add it to our queue.
- wp_trash_post() : mixed
- A post got moved to the trash. Remove the URL from the scan results.
- addUrlToScanner() : mixed
- Add a changed permalink URL to the scanner queue. It also respects multilingual websites and adds all language translations to the scanner queue (e.g. `/de/my-post` and `/en/my-post`).
- fromPost() : mixed
- Check if the post can be queried publicly and add it to our queue.
- getPermalink() : mixed
- Get permalink to a given post which can be inserted to the scanner.
Constants
SKIP_POST_TYPE
In some cases it does not make sense to scan viewable post types as they act e.g. as "template" posts which are reused in publicly available posts and pages.
public
mixed
SKIP_POST_TYPE
= []
E.g. elementor_library
still needs to be scanned as the post type is resused in Elementor pages and
they do not get automatically scanned. In a perfect world, when elementor_library
got changed, it needs
to add all URLs of the posts which uses it.
USE_PREVIEW_LINK_FOR_POST_TYPE
In some cases, custom post types are used in "Draft"-always state or private, so let's use the preview URL (`?preview=true`) instead of the permalink URL.
public
mixed
USE_PREVIEW_LINK_FOR_POST_TYPE
= [
// [Plugin Comp] https://wordpress.org/plugins/coming-soon/
'seedprod',
]
Properties
$scanner
private
mixed
$scanner
Methods
__construct()
C'tor.
public
__construct(Scanner $scanner) : mixed
Parameters
- $scanner : Scanner
Tags
delete_post()
A post got deleted. Remove the URL from the scan results.
public
delete_post(int $post_id) : mixed
Parameters
- $post_id : int
getPluginConstantPrefix()
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
public
getPluginConstantPrefix() : string
Tags
Return values
stringpost_updated()
The `post_updated` hook is fired before `save_post` so we can identify if the slug has been changed (parent or slug).
public
post_updated(int $post_id, WP_Post $post_after, WP_Post $post_before) : mixed
Parameters
- $post_id : int
- $post_after : WP_Post
- $post_before : WP_Post
save_post()
A post got updated or created, add it to our queue.
public
save_post(int $post_id, WP_Post $post) : mixed
Parameters
- $post_id : int
- $post : WP_Post
wp_trash_post()
A post got moved to the trash. Remove the URL from the scan results.
public
wp_trash_post(int $post_id) : mixed
Parameters
- $post_id : int
addUrlToScanner()
Add a changed permalink URL to the scanner queue. It also respects multilingual websites and adds all language translations to the scanner queue (e.g. `/de/my-post` and `/en/my-post`).
protected
addUrlToScanner(string $url) : mixed
Parameters
- $url : string
fromPost()
Check if the post can be queried publicly and add it to our queue.
protected
fromPost(WP_Post $post) : mixed
Parameters
- $post : WP_Post
getPermalink()
Get permalink to a given post which can be inserted to the scanner.
protected
getPermalink(WP_Post $post) : mixed
Parameters
- $post : WP_Post