- Implement encryption helpers for storing and retrieving the Personal Access Token (PAT). - Create REST API endpoints for triggering sync, checking sync status, and handling webhooks. - Develop the sync engine to fetch pages from the Git repository, create/update WordPress pages, and trash removed pages. - Add functionality for previewing and applying theme files from the repository. - Set up plugin activation and deactivation hooks to manage default options and scheduled tasks. - Implement uninstall routine to clean up plugin options and metadata from posts.
37 lines
1.0 KiB
PHP
37 lines
1.0 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' );
|
|
|
|
// Remove sync metadata from posts
|
|
$posts = get_posts( [
|
|
'post_type' => 'page',
|
|
'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_source' );
|
|
delete_post_meta( $post_id, '_oribi_sync_last_run' );
|
|
}
|
|
|
|
// Clear any scheduled cron
|
|
wp_clear_scheduled_hook( 'oribi_sync_cron_run' );
|