<?php

use auctionforge\inc\controllers\MultiLanguageSupport;
use auctionforge\inc\helpers\SettingsHelper;

if (!empty($_SERVER['DOCUMENT_ROOT'])) {
    die("Access denied");
}

define('CRON_TASKS_BASE_PATH', __DIR__);
define('WP_USE_THEMES', false);
require(CRON_TASKS_BASE_PATH . '/../../../../wp-load.php');

if (!is_plugin_active(basename(dirname(__DIR__)) . '/' . basename(dirname(__DIR__)) . '.php')) {
    die("Plugin AuctionForge disabled\r\n");
}

$args = array(
    'post_type' => 'lot',
    'numberposts' => 100,
    'post_status' => array(
        SettingsHelper::STATUS_PUBLISH,
        SettingsHelper::STATUS_DRAFT,
        SettingsHelper::STATUS_TRASH,
        SettingsHelper::STATUS_FUTURE
    ),
    'lang' => MultiLanguageSupport::getSecondLangCode(),
);

while ($lots = get_posts($args)) {
    /** @var WP_Post $lot */
    foreach ($lots as $lot) {
        pll_set_post_language($lot->ID, pll_default_language());
    }
}