webberzone.dev Recent

Push_Handler class Pro only

Push_Handler

Push_Handler class.

Namespace: WebberZone\Knowledge_Base\Pro\GitHub
Since: 3.1.0
Source: includes/github/class-push-handler.php line 26

Methods

__construct()

Constructor.

Since: 3.1.0
Line: 44

public function __construct( API $api );
TypeNameDescription
API$apiGitHub API instance.

push_post()

Push a KB article to its source GitHub file.

Returns early (success=true) when the post is not linked to GitHub or no enabled mapping is configured for its repository — neither is an error.

Returns success=true with unchanged=true when the generated Markdown is byte-for-byte identical to the current GitHub file (SHA match), so the caller can surface a friendly “nothing to push” message.

Since: 3.1.0
Line: 85

public function push_post( int $post_id ): array;
TypeNameDescription
int$post_idPost ID.

Returns: array — bool, commit_url?: string, unchanged?: bool, error?: string}

on_save_post()

Push to GitHub automatically after a KB article is saved.

Skipped when:

  • The global “Auto-push on save” setting is off.
  • The save is an autosave or a revision.
  • The save was triggered by the webhook import (flag set by Import_Processor).

Since: 3.1.0
Line: 233

public function on_save_post( int $post_id ): void;
TypeNameDescription
int$post_idPost ID.

Returns: void

cron_push_post()

Cron callback: push a KB article to GitHub in the background.

Since: 3.1.0
Line: 263

public function cron_push_post( int $post_id ): void;
TypeNameDescription
int$post_idPost ID.

Returns: void

ajax_push_post()

AJAX handler for the manual “Push to GitHub” meta box button.

Since: 3.1.0
Line: 278

public function ajax_push_post(  ): void;

Returns: void

ajax_pull_post()

AJAX handler for the manual “Pull from GitHub” meta box button.

Fetches the current file from GitHub and re-imports it into the post, overwriting the post content and meta with whatever is on the remote.

Since: 3.1.0
Line: 331

public function ajax_pull_post(  ): void;

Returns: void

register_meta_box()

Register the GitHub meta box on the KB article edit screen.

Since: 3.1.0
Line: 403

public function register_meta_box(  ): void;

Returns: void

render_meta_box()

Render the GitHub meta box.

Shows source file, last-synced date, last-push commit link, and a “Push to GitHub” button whenever the article is linked and an enabled mapping exists for its repository.

Since: 3.1.0
Line: 426

public function render_meta_box( WP_Post $post ): void;
TypeNameDescription
\WP_Post$postCurrent post.

Returns: void

enqueue_scripts()

Enqueue the push meta box script on the KB article edit screen.

Since: 3.1.0
Line: 491

public function enqueue_scripts( string $hook_suffix ): void;
TypeNameDescription
string$hook_suffixAdmin page hook suffix.

Returns: void