webberzone.dev Recent

Base_Importer class

Base_Importer

Abstract Base_Importer class.

Provides shared logic for all plugin-to-KB importers: slug preservation, idempotency meta, post/term copy helpers, and AJAX batch scaffolding.

Namespace: WebberZone\Knowledge_Base\Admin\Importers
Since: 3.2.0
Source: includes/admin/importers/class-base-importer.php line 23

Methods

get_label()

Human-readable plugin name shown in the UI.

Line: 105

public function get_label(  ): string;

Returns: string

get_slug()

Machine slug used in URL params and meta values (e.g. ‘basepress’).

Line: 112

public function get_slug(  ): string;

Returns: string

detect()

Return true if the source plugin has data available to import.

Result is cached for the lifetime of the object so repeated calls (e.g. Tools page card + selector screen) never re-query the database.

Line: 122

public function detect(  ): bool;

Returns: bool

get_source_settings()

Return key source settings needed for the import preview UI.

Must include at minimum: ‘base_slug’ => string (URL base slug of source plugin) ‘has_category_url’ => bool (whether category appears in article URL)

Line: 145

public function get_source_settings(  ): array;

Returns: array — mixed>

get_post_count()

Total number of source posts available to import.

Line: 152

public function get_post_count(  ): int;

Returns: int

get_term_count()

Total number of source terms available to import.

Line: 159

public function get_term_count(  ): int;

Returns: int

import_terms()

Import all terms from the source plugin.

Must handle hierarchy (parents before children) and set product_id term meta on wzkb_category terms where applicable.

Line: 169

public function import_terms(  ): array;

Returns: array — int, skipped: int, errors: string[]}

import_posts_batch()

Import a batch of posts.

Line: 178

public function import_posts_batch( int $offset, int $batch_size ): array;
TypeNameDescription
int$offsetPagination offset.
int$batch_sizeNumber of posts to process.

Returns: array — int, skipped: int, errors: string[], processed: int}

get_suggested_kb_slug()

Suggest the WZ KB base slug based on the source plugin’s current URL base.

Line: 189

public function get_suggested_kb_slug(  ): string;

Returns: string

get_url_depth_note()

Return a note about URL depth changes after migration.

Returns an upsell when the source plugin includes sections in article URLs but the current license cannot use custom permalink structures to match them. Returns empty when URLs will match, or when the source URLs are already flat.

Line: 203

public function get_url_depth_note(  ): string;

Returns: string

finalize_import()

Called once after all post batches complete.

Override in subclasses to apply post-import configuration such as permalink settings.

Since: 3.1.0
Line: 567

public function finalize_import(  ): void;

Returns: void

get_before_import_notices()

Return additional warning strings shown in the “Before you continue” box.

Override in subclasses to add importer-specific pre-flight instructions. Each string is rendered as a plain-text list item.

Line: 577

public function get_before_import_notices(  ): array;

Returns: array

get_preview_data()

Build a preview data array for the AJAX preview response.

Line: 586

public function get_preview_data(  ): array;

Returns: array — int, terms: int, suggested_slug: string, url_note: string, details: list, sections: list<array{heading: string, items: list}>}