can_use_premium_code() ? __( 'Promote', 'ai-publisher' ) : __( 'Promote (Pro)', 'ai-publisher' ) );
add_submenu_page(
self::MENU_SLUG,
__( 'Promote', 'ai-publisher' ),
$promo_menu_title,
'manage_options',
'aipub_promote',
[self::class, 'page_promote']
);
}
/* --------------------------------------------------------------------- */
/* Page render callbacks */
/* --------------------------------------------------------------------- */
public static function page_settings() : void {
self::enqueue_assets();
self::template( 'settings-general.php' );
}
public static function page_brand() : void {
self::enqueue_assets();
self::template( 'settings-brand.php' );
}
/* ---------------------------------------------------------------------
* SEO Keywords page – render or show notice
* ------------------------------------------------------------------- */
public static function page_keywords() : void {
self::enqueue_assets();
self::template( 'settings-keywords.php' );
}
public static function page_generate() : void {
self::enqueue_assets();
self::template( 'generate-posts.php' );
}
public static function page_promote() : void {
self::enqueue_assets();
$tpl = ( aipub_fs()->can_use_premium_code() ? 'promote.php' : 'promote-upgrade.php' );
self::template( $tpl );
}
/* --------------------------------------------------------------------- */
/* Form handlers (admin_post_*) */
/* --------------------------------------------------------------------- */
public static function save_keywords() : void {
check_admin_referer( 'aipub_kw_nonce' );
$keywords = ( isset( $_POST['keywords'] ) ? ( is_array( $_POST['keywords'] ) ? array_filter( array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['keywords'] ) ), 'strlen' ) : array_filter( array_map( 'sanitize_text_field', preg_split( '/[\\r\\n,;]+/', sanitize_textarea_field( wp_unslash( $_POST['keywords'] ) ) ) ) ) ) : [] );
Keywords::save( $keywords );
wp_safe_redirect( admin_url( 'admin.php?page=aipub_keywords&aipub_notice=saved' ) );
exit;
}
/* --------------------------------------------------------------------- */
/* Helpers */
/* --------------------------------------------------------------------- */
/** True when the Brand Strategy wizard has been completed. */
private static function brand_complete() : bool {
return Brand_Strategy::is_complete();
}
/** Require a template from admin/templates/. */
private static function template( string $file ) : void {
require AIPUB_DIR . 'admin/templates/' . $file;
}
/**
* Return the HTML for the "Start Your Free Trial" upgrade banner.
*/
public static function render_upgrade_banner() : string {
return sprintf(
'
',
esc_html__( 'Start Your Free Trial', 'ai-publisher' ),
esc_html__( 'Unlock every Pro feature, advanced AI models, daily & weekly scheduling, file attachments, Promote tools, and generate up to 3 posts per day. Upgrade anytime for unlimited, restriction-free access.', 'ai-publisher' ),
esc_url( aipub_fs()->get_trial_url() ),
esc_html__( 'Upgrade Now', 'ai-publisher' )
);
}
/**
* Enqueue shared admin CSS/JS once per TransformX screen.
*/
private static function enqueue_assets() : void {
// Only load on our plugin screens (any page slug starting with "aipub_") to avoid 404s / bloat.
$screen = get_current_screen();
if ( !$screen || strpos( $screen->base, 'aipub_' ) === false ) {
return;
}
if ( function_exists( 'wp_enqueue_media' ) ) {
wp_enqueue_media();
}
$base_url = plugin_dir_url( AIPUB_FILE ) . 'assets/';
$base_path = plugin_dir_path( AIPUB_FILE ) . 'assets/';
$js = 'js/admin.js';
$promote_js = 'js/promote__premium_only.js';
$css = 'css/admin.css';
// Register only if the physical files exist to prevent HTTP 404.
if ( file_exists( $base_path . $js ) ) {
wp_register_script(
'ai_publisher_admin',
$base_url . $js,
['jquery'],
filemtime( $base_path . $js ),
true
);
// Localise aipubAjax once here.
wp_localize_script( 'ai_publisher_admin', 'aipubAjax', [
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
'nonce' => wp_create_nonce( 'aipub_nonce' ),
] );
wp_enqueue_script( 'ai_publisher_admin' );
}
if ( aipub_fs()->is__premium_only() && false !== strpos( $screen->base, 'aipub_promote' ) && file_exists( $base_path . $promote_js ) ) {
wp_enqueue_script(
'aipub_promote',
$base_url . $promote_js,
['jquery'],
filemtime( $base_path . $promote_js ),
true
);
}
if ( file_exists( $base_path . $css ) ) {
wp_enqueue_style(
'ai_publisher_admin',
$base_url . $css,
[],
filemtime( $base_path . $css )
);
}
}
/**
* AJAX handler for generating Brand Strategy via OpenAI.
*/
public static function ajax_generate_brand() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
( new Brand_Strategy() )->generate_stream();
} catch ( \Exception $e ) {
header( 'HTTP/1.1 500 Internal Server Error' );
echo esc_html( $e->getMessage() );
}
exit;
}
/** Initialize Brand Strategy generation session. */
public static function ajax_init_brand() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
( new Brand_Strategy() )->init_session();
wp_send_json_success();
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/** Generate one Brand Strategy element. */
public static function ajax_generate_brand_element() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$index = ( isset( $_POST['index'] ) ? intval( wp_unslash( $_POST['index'] ) ) : 0 );
try {
$data = ( new Brand_Strategy() )->generate_element( $index );
wp_send_json_success( $data );
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/** Finalize Brand Strategy session and save results. */
public static function ajax_finish_brand() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
( new Brand_Strategy() )->end_session();
wp_send_json_success();
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* Start asynchronous Brand Strategy generation.
*/
public static function ajax_start_brand_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
$job_id = Brand_Strategy::start_async_job();
wp_send_json_success( [
'job_id' => $job_id,
] );
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* Poll asynchronous Brand Strategy job.
*/
public static function ajax_check_brand_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$job_id = sanitize_text_field( wp_unslash( $_POST['job_id'] ?? '' ) );
$session = ( Context::load_json( 'brand-session.json' ) ?: [] );
if ( ($session['job_id'] ?? '') !== $job_id ) {
wp_send_json_error( __( 'Job not found.', 'ai-publisher' ) );
}
$last = ( isset( $session['last_update'] ) ? (int) $session['last_update'] : 0 );
if ( in_array( $session['job_status'] ?? '', ['running', 'queued'], true ) && $last && time() - $last > \AiPublisher\Brand_Strategy::TIMEOUT_SECS ) {
$session['job_status'] = 'error';
$session['error'] = __( 'Job timed out', 'ai-publisher' );
Context::save_json( 'brand-session.json', $session );
}
$data = [
'status' => $session['job_status'] ?? 'queued',
'progress' => $session['progress'] ?? '',
];
if ( isset( $session['result'] ) ) {
$data['result'] = $session['result'];
}
if ( isset( $session['error'] ) ) {
$data['error'] = $session['error'];
}
wp_send_json_success( $data );
}
/**
* AJAX handler for saving edited Brand Strategy.
*/
public static function ajax_save_brand() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$data = ( isset( $_POST['aipub_brand'] ) ? map_deep( wp_unslash( $_POST['aipub_brand'] ), 'sanitize_textarea_field' ) : [] );
try {
Brand_Strategy::save( $data );
wp_send_json_success();
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* AJAX handler for saving general settings.
*/
public static function ajax_save_settings() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$data = ( isset( $_POST['data'] ) ? map_deep( wp_unslash( $_POST['data'] ), 'sanitize_text_field' ) : [] );
$existing_api = Settings::api_key();
$api_key_param = ( isset( $data['api_key'] ) ? Settings::sanitize_api_key( $data['api_key'] ) : null );
// OpenAI API key (only if provided)
if ( null !== $api_key_param ) {
if ( empty( $api_key_param ) ) {
wp_send_json_error( __( 'Invalid OpenAI API Key.', 'ai-publisher' ) );
}
if ( $api_key_param !== $existing_api ) {
if ( !OpenAI::verify_key( $api_key_param ) ) {
wp_send_json_error( __( 'OpenAI API Key validation failed.', 'ai-publisher' ) );
}
update_option( Settings::KEY_API, $api_key_param );
}
}
// AI model selection
if ( isset( $data['ai_model'] ) ) {
$model = sanitize_text_field( $data['ai_model'] );
update_option( Settings::KEY_MODEL, $model );
}
// Scheduling interval and count
if ( isset( $data['schedule_interval'], $data['posts_per_interval'] ) ) {
$schedule = [
'interval' => sanitize_text_field( $data['schedule_interval'] ),
'count' => (int) $data['posts_per_interval'],
];
$schedule = Settings::sanitize_schedule( $schedule );
update_option( Settings::KEY_SCHEDULE, $schedule );
// Reschedule Cron event immediately based on updated settings
Cron::maybe_reschedule();
}
// Default post status
if ( isset( $data['default_post_status'] ) ) {
$status = sanitize_text_field( $data['default_post_status'] );
update_option( Settings::KEY_STATUS, Settings::sanitize_status( $status ) );
}
// Attached file IDs
if ( isset( $data['attachments'] ) ) {
$att = array_map( 'intval', (array) $data['attachments'] );
update_option( Settings::KEY_ATTACH, Settings::sanitize_int_array( $att ) );
}
// Ensure an OpenAI API key exists before completing
if ( empty( Settings::api_key() ) ) {
wp_send_json_error( __( 'OpenAI API Key required.', 'ai-publisher' ) );
}
wp_send_json_success( [
'redirect' => admin_url( 'admin.php?page=aipub_brand&aipub_notice=saved' ),
] );
}
/**
* AJAX handler for generating SEO Keywords via OpenAI.
*/
public static function ajax_generate_keywords() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
Keywords::generate();
$keywords = get_option( 'aipub_keywords', [] );
wp_send_json_success( [
'keywords' => $keywords,
] );
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* AJAX handler for saving edited SEO Keywords.
*/
public static function ajax_save_keywords() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$keywords = ( isset( $_POST['keywords'] ) ? array_filter( array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['keywords'] ) ), 'strlen' ) : [] );
try {
Keywords::save( $keywords );
wp_send_json_success();
} catch ( \Exception $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* AJAX handler for generating posts via AI.
*/
public static function ajax_generate_post() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
// Prevent manual runs when automatic scheduling is active
$schedule = Settings::schedule();
if ( 'manual' !== $schedule['interval'] ) {
wp_send_json_error( esc_html__( 'Manual post generation is disabled while automatic scheduling is active. Switch to Manual mode in the Settings to enable this button.', 'ai-publisher' ) );
}
// Prevent PHP timeout for long AI post generation
$threadid = ( isset( $_POST['threadid'] ) ? sanitize_text_field( wp_unslash( $_POST['threadid'] ) ) : '' );
$vectorid = ( isset( $_POST['vectorid'] ) ? sanitize_text_field( wp_unslash( $_POST['vectorid'] ) ) : '' );
$topic = ( isset( $_POST['topic'] ) ? sanitize_text_field( wp_unslash( $_POST['topic'] ) ) : '' );
$keywords = ( isset( $_POST['keywords'] ) ? array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['keywords'] ) ) : [] );
ignore_user_abort( true );
try {
$post_id = aipub_with_time_limit( Brand_Strategy::TIMEOUT_SECS, function () use(
$threadid,
$vectorid,
$topic,
$keywords
) {
if ( $threadid && $vectorid && $topic ) {
return Generator::manual_run_with_topic(
$threadid,
$vectorid,
$topic,
$keywords
);
}
return Generator::manual_run();
} );
// Reschedule next automatic run according to current settings.
Cron::maybe_reschedule();
$resp = [
'post_id' => $post_id,
'post_edit' => admin_url( 'post.php?post=' . $post_id . '&action=edit' ),
'post_view' => get_permalink( $post_id ),
];
wp_send_json_success( $resp );
} catch ( \Throwable $e ) {
wp_send_json_error( $e->getMessage() );
}
}
/**
* Start asynchronous post generation and return job ID.
*/
public static function ajax_start_post_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$schedule = Settings::schedule();
if ( 'manual' !== $schedule['interval'] ) {
wp_send_json_error( __( 'Manual post generation is disabled while automatic scheduling is active.', 'ai-publisher' ) );
}
list( $allowed, $msg ) = Limits::can_generate();
if ( !$allowed ) {
wp_send_json_error( esc_html( $msg ) );
}
$threadid = ( isset( $_POST['threadid'] ) ? sanitize_text_field( wp_unslash( $_POST['threadid'] ) ) : '' );
$vectorid = ( isset( $_POST['vectorid'] ) ? sanitize_text_field( wp_unslash( $_POST['vectorid'] ) ) : '' );
$topic = ( isset( $_POST['topic'] ) ? sanitize_text_field( wp_unslash( $_POST['topic'] ) ) : '' );
$keywords = ( isset( $_POST['keywords'] ) ? array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['keywords'] ) ) : [] );
$job_id = Generator::start_async_generation(
$threadid,
$vectorid,
$topic,
$keywords
);
wp_send_json_success( [
'job_id' => $job_id,
] );
}
/**
* Poll asynchronous post generation job.
*/
public static function ajax_check_post_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$job_id = sanitize_text_field( wp_unslash( $_POST['job_id'] ?? '' ) );
$session = ( Context::load_json( 'session.json' ) ?: [] );
if ( ($session['job_id'] ?? '') !== $job_id ) {
wp_send_json_error( __( 'Job not found.', 'ai-publisher' ) );
}
$data = [
'status' => $session['job_status'] ?? 'queued',
'progress' => $session['progress'] ?? '',
];
if ( isset( $session['result'] ) ) {
$data['result'] = $session['result'];
}
if ( isset( $session['error'] ) ) {
$data['error'] = $session['error'];
}
wp_send_json_success( $data );
}
/** Delete the session.json file after job completion. */
public static function ajax_cleanup_session() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
Generator::cleanup_session();
wp_send_json_success();
}
/** Run draft generation step. */
public static function ajax_generate_draft() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
( new Generator() )->generate_draft( true );
} catch ( \Throwable $e ) {
header( 'HTTP/1.1 500 Internal Server Error' );
echo esc_html( $e->getMessage() );
}
exit;
}
/** Run QA step. */
public static function ajax_run_qa() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
( new Generator() )->run_qa_stage( true );
} catch ( \Throwable $e ) {
header( 'HTTP/1.1 500 Internal Server Error' );
echo esc_html( $e->getMessage() );
}
exit;
}
/** Finalize post after QA. */
public static function ajax_finalize_post() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
( new Generator() )->finalize_post( true );
} catch ( \Throwable $e ) {
header( 'HTTP/1.1 500 Internal Server Error' );
echo esc_html( $e->getMessage() );
}
exit;
}
/** Generate image and insert post. */
public static function ajax_generate_image() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
( new Generator() )->generate_image( true );
} catch ( \Throwable $e ) {
header( 'HTTP/1.1 500 Internal Server Error' );
echo esc_html( $e->getMessage() );
}
exit;
}
/** Generate FAQ schema for a post immediately. */
public static function ajax_generate_faq() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$post_id = ( isset( $_POST['post_id'] ) ? intval( wp_unslash( $_POST['post_id'] ) ) : 0 );
if ( !$post_id ) {
wp_send_json_error( __( 'Invalid post ID.', 'ai-publisher' ), 400 );
}
ignore_user_abort( true );
try {
$schema = aipub_with_time_limit( Brand_Strategy::TIMEOUT_SECS, function () use($post_id) {
return Faq::generate( $post_id );
} );
wp_send_json_success( [
'result' => $schema,
] );
} catch ( \Throwable $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* Start asynchronous FAQ generation and return job ID.
*/
public static function ajax_start_faq_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$post_id = ( isset( $_POST['post_id'] ) ? intval( wp_unslash( $_POST['post_id'] ) ) : 0 );
if ( !$post_id ) {
wp_send_json_error( __( 'Invalid post ID.', 'ai-publisher' ), 400 );
}
try {
$job_id = Faq::start_async_job( $post_id );
wp_send_json_success( [
'job_id' => $job_id,
] );
} catch ( \Throwable $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* Poll asynchronous FAQ generation job.
*/
public static function ajax_check_faq_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$job_id = sanitize_text_field( wp_unslash( $_POST['job_id'] ?? '' ) );
$session = ( Context::load_json( 'faq-session.json' ) ?: [] );
if ( ($session['job_id'] ?? '') !== $job_id ) {
wp_send_json_error( __( 'Job not found.', 'ai-publisher' ) );
}
$data = [
'status' => $session['job_status'] ?? 'queued',
];
if ( isset( $session['result'] ) ) {
$data['result'] = $session['result'];
}
if ( isset( $session['error'] ) ) {
$data['error'] = $session['error'];
}
wp_send_json_success( $data );
}
/**
* AJAX handler for suggesting topics via AI.
*/
public static function ajax_suggest_topics() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
ignore_user_abort( true );
try {
$data = aipub_with_time_limit( Brand_Strategy::TIMEOUT_SECS, fn() => Generator::suggest_topics() );
wp_send_json_success( $data );
} catch ( \Throwable $e ) {
wp_send_json_error( $e->getMessage() );
}
}
/**
* Start asynchronous topic suggestion job.
*/
public static function ajax_start_topic_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
try {
$job_id = Generator::start_async_topic_job();
wp_send_json_success( [
'job_id' => $job_id,
] );
} catch ( \Throwable $e ) {
wp_send_json_error( $e->getMessage(), 500 );
}
}
/**
* Poll asynchronous topic suggestion job.
*/
public static function ajax_check_topic_job() : void {
check_ajax_referer( 'aipub_nonce', 'nonce' );
if ( !current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Forbidden', 403 );
}
$job_id = sanitize_text_field( wp_unslash( $_POST['job_id'] ?? '' ) );
$session = ( Context::load_json( 'topic-session.json' ) ?: [] );
if ( ($session['job_id'] ?? '') !== $job_id ) {
wp_send_json_error( __( 'Job not found.', 'ai-publisher' ) );
}
$last = ( isset( $session['last_update'] ) ? (int) $session['last_update'] : 0 );
if ( in_array( $session['job_status'] ?? '', ['running', 'queued'], true ) && $last && time() - $last > \AiPublisher\Generator::TOPIC_TIMEOUT_SECS ) {
$session['job_status'] = 'error';
$session['error'] = __( 'Job timed out', 'ai-publisher' );
Context::save_json( 'topic-session.json', $session );
}
$data = [
'status' => $session['job_status'] ?? 'queued',
'progress' => $session['progress'] ?? '',
];
if ( isset( $session['result'] ) ) {
$data['result'] = $session['result'];
}
if ( isset( $session['error'] ) ) {
$data['error'] = $session['error'];
}
wp_send_json_success( $data );
}
}
add_action( 'wp_ajax_aipub_generate_brand', [__NAMESPACE__ . '\\Admin', 'ajax_generate_brand'] );
add_action( 'wp_ajax_aipub_init_brand', [__NAMESPACE__ . '\\Admin', 'ajax_init_brand'] );
add_action( 'wp_ajax_aipub_generate_brand_element', [__NAMESPACE__ . '\\Admin', 'ajax_generate_brand_element'] );
add_action( 'wp_ajax_aipub_finish_brand', [__NAMESPACE__ . '\\Admin', 'ajax_finish_brand'] );
add_action( 'wp_ajax_aipub_start_brand_job', [__NAMESPACE__ . '\\Admin', 'ajax_start_brand_job'] );
add_action( 'wp_ajax_aipub_check_brand_job', [__NAMESPACE__ . '\\Admin', 'ajax_check_brand_job'] );
add_action( 'wp_ajax_aipub_save_brand', [__NAMESPACE__ . '\\Admin', 'ajax_save_brand'] );
add_action( 'wp_ajax_aipub_save_settings', [__NAMESPACE__ . '\\Admin', 'ajax_save_settings'] );
add_action( 'wp_ajax_aipub_generate_keywords', [__NAMESPACE__ . '\\Admin', 'ajax_generate_keywords'] );
add_action( 'wp_ajax_aipub_save_keywords', [__NAMESPACE__ . '\\Admin', 'ajax_save_keywords'] );
add_action( 'wp_ajax_aipub_generate_post', [__NAMESPACE__ . '\\Admin', 'ajax_generate_post'] );
add_action( 'wp_ajax_aipub_generate_draft', [__NAMESPACE__ . '\\Admin', 'ajax_generate_draft'] );
add_action( 'wp_ajax_aipub_run_qa', [__NAMESPACE__ . '\\Admin', 'ajax_run_qa'] );
add_action( 'wp_ajax_aipub_finalize_post', [__NAMESPACE__ . '\\Admin', 'ajax_finalize_post'] );
add_action( 'wp_ajax_aipub_generate_image', [__NAMESPACE__ . '\\Admin', 'ajax_generate_image'] );
add_action( 'wp_ajax_aipub_generate_faq', [__NAMESPACE__ . '\\Admin', 'ajax_generate_faq'] );
add_action( 'wp_ajax_aipub_start_faq_job', [__NAMESPACE__ . '\\Admin', 'ajax_start_faq_job'] );
add_action( 'wp_ajax_aipub_check_faq_job', [__NAMESPACE__ . '\\Admin', 'ajax_check_faq_job'] );
add_action( 'wp_ajax_aipub_suggest_topics', [__NAMESPACE__ . '\\Admin', 'ajax_suggest_topics'] );
add_action( 'wp_ajax_aipub_start_topic_job', [__NAMESPACE__ . '\\Admin', 'ajax_start_topic_job'] );
add_action( 'wp_ajax_aipub_check_topic_job', [__NAMESPACE__ . '\\Admin', 'ajax_check_topic_job'] );
add_action( 'wp_ajax_aipub_start_post_job', [__NAMESPACE__ . '\\Admin', 'ajax_start_post_job'] );
add_action( 'wp_ajax_aipub_check_post_job', [__NAMESPACE__ . '\\Admin', 'ajax_check_post_job'] );
add_action( 'wp_ajax_aipub_cleanup_session', [__NAMESPACE__ . '\\Admin', 'ajax_cleanup_session'] );