Add post synchronization functionality for Markdown files
- 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.
This commit is contained in:
@@ -44,36 +44,6 @@ function oribi_sync_detect_pages_prefix(): string {
|
||||
return 'pages/';
|
||||
}
|
||||
|
||||
// ─── Auto-push on page save ──────────────────────────────────────────────────
|
||||
add_action( 'save_post_page', 'oribi_sync_maybe_push_on_save', 20, 3 );
|
||||
|
||||
/**
|
||||
* Push a synced page to the repo whenever it is saved.
|
||||
*
|
||||
* Only fires for pages that were previously pulled (have _oribi_sync_checksum
|
||||
* meta), skips autosaves, revisions, and non-publish statuses.
|
||||
* Uses a static guard to prevent re-entry when we update post meta after push.
|
||||
*/
|
||||
function oribi_sync_maybe_push_on_save( int $post_id, WP_Post $post, bool $update ): void {
|
||||
// Guard: only on genuine content saves
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
||||
if ( wp_is_post_revision( $post_id ) ) return;
|
||||
if ( $post->post_status !== 'publish' ) return;
|
||||
|
||||
// Guard: only pages that came from a sync (have checksum meta)
|
||||
$checksum = get_post_meta( $post_id, '_oribi_sync_checksum', true );
|
||||
if ( empty( $checksum ) ) return;
|
||||
|
||||
// Guard: prevent re-entry when push updates meta on the same post
|
||||
static $pushing = [];
|
||||
if ( isset( $pushing[ $post_id ] ) ) return;
|
||||
$pushing[ $post_id ] = true;
|
||||
|
||||
oribi_sync_push_page( $post_id );
|
||||
|
||||
unset( $pushing[ $post_id ] );
|
||||
}
|
||||
|
||||
// ─── Generic authenticated request helpers ────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user