- Implemented a parser for YAML front-matter in Markdown files. - Developed functions to convert Markdown content to HTML. - Created a pipeline to sync WordPress posts from a specified folder in a Git repository. - Added media import capabilities to handle images referenced in Markdown. - Implemented author resolution and post slug generation. - Included error handling and logging for sync operations. - Enabled trashing of posts that are no longer present in the repository.
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Oribi Sync — Uninstall routine.
|
|
*
|
|
* Called by WordPress when the plugin is deleted via the admin UI.
|
|
* Removes all plugin options from the database.
|
|
*/
|
|
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit;
|
|
|
|
delete_option( 'oribi_sync_repo' );
|
|
delete_option( 'oribi_sync_branch' );
|
|
delete_option( 'oribi_sync_provider' );
|
|
delete_option( 'oribi_sync_pat' );
|
|
delete_option( 'oribi_sync_last_run' );
|
|
delete_option( 'oribi_sync_log' );
|
|
delete_option( 'oribi_sync_webhook_secret' );
|
|
delete_option( 'oribi_sync_theme_applied' );
|
|
delete_option( 'oribi_sync_push_log' );
|
|
delete_option( 'oribi_sync_posts_enabled' );
|
|
delete_option( 'oribi_sync_posts_folder' );
|
|
|
|
// Remove sync metadata from pages and posts
|
|
$posts = get_posts( [
|
|
'post_type' => [ 'page', 'post' ],
|
|
'post_status' => 'any',
|
|
'posts_per_page' => -1,
|
|
'meta_key' => '_oribi_sync_checksum',
|
|
'fields' => 'ids',
|
|
] );
|
|
|
|
foreach ( $posts as $post_id ) {
|
|
delete_post_meta( $post_id, '_oribi_sync_checksum' );
|
|
delete_post_meta( $post_id, '_oribi_sync_git_sha' );
|
|
delete_post_meta( $post_id, '_oribi_sync_source' );
|
|
delete_post_meta( $post_id, '_oribi_sync_last_run' );
|
|
delete_post_meta( $post_id, '_oribi_sync_last_push' );
|
|
delete_post_meta( $post_id, '_oribi_sync_pr_url' );
|
|
}
|
|
|
|
// Remove origin src meta from media attachments
|
|
$attachments = get_posts( [
|
|
'post_type' => 'attachment',
|
|
'post_status' => 'any',
|
|
'posts_per_page' => -1,
|
|
'meta_key' => '_oribi_sync_origin_src',
|
|
'fields' => 'ids',
|
|
] );
|
|
foreach ( $attachments as $att_id ) {
|
|
delete_post_meta( $att_id, '_oribi_sync_origin_src' );
|
|
}
|
|
|
|
// Clear any scheduled cron
|
|
wp_clear_scheduled_hook( 'oribi_sync_cron_run' );
|