*/ $dir = __DIR__; for ($i = 0; $i < 10; $i++) { if (file_exists($dir . '/wp-load.php')) { break; } $dir = dirname($dir); } if (!file_exists($dir . '/wp-load.php')) { fwrite(STDERR, "[Automatic AI Posts] wp-load.php not found.\n"); exit(1); } set_time_limit(0); ignore_user_abort(true); ini_set('memory_limit', '-1'); define('WP_INSTALLING', false); require_once $dir . '/wp-load.php'; $author_id = isset($argv[1]) ? (int) $argv[1] : 0; register_shutdown_function(static function (): void { $error = error_get_last(); if (!$error || !in_array($error['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) { return; } \AAP\Modules\Logs\Logger::error( 'Fatal PHP error: ' . $error['message'] . ' at ' . $error['file'] . ':' . $error['line'], 'pipeline' ); \AAP\Modules\Pipeline\RunState::stop(); }); try { do_action('aap_run_pipeline_cli', $author_id); } catch (\Throwable $e) { \AAP\Modules\Logs\Logger::error( 'Uncaught exception: ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine(), 'pipeline' ); \AAP\Modules\Pipeline\RunState::stop(); exit(1); }