add_action('template_redirect', function () { if (!isset($_GET['run_featured_image_test'])) { return; } if (!current_user_can('manage_options')) { wp_die('Not allowed'); } echo "
Starting bulk featured image test...\n\n";

    $posts = get_posts([
        'numberposts' => 10,
        'post_type'   => 'post',
        'post_status' => 'publish'
    ]);

    if (empty($posts)) {
        wp_die("No posts found");
    }

    require_once(ABSPATH . 'wp-admin/includes/image.php');
    require_once(ABSPATH . 'wp-admin/includes/file.php');
    require_once(ABSPATH . 'wp-admin/includes/media.php');

    $access_key = 'Q9f-Dqt7uV7-mGPUg_Q6BF01CmY6NulPvzc-AvITU8I';

    foreach ($posts as $post) {

        echo "-----------------------------\n";
        echo "Post ID: {$post->ID}\n";

        if (has_post_thumbnail($post->ID)) {
            echo "SKIPPED: already has image\n";
            continue;
        }

        $title = get_the_title($post->ID);
        echo "Title: {$title}\n";

       // Build smarter query attempts (MAX 3 tries)
$words = preg_split('/\s+/', strtolower($title));

// better stopwords
$stopwords = [
    'the','and','for','with','this','that','from','your','how','why','what',
    'are','was','were','will','can','you',
    'best','top','guide','tips','ways','strategies','2024','2025'
];

// clean keywords
$keywords = array_values(array_filter(array_diff($words, $stopwords), function($word) {
    return strlen($word) > 3 && !is_numeric($word);
}));

// prioritize visual words
$visual_words = [
    'fitness','workout','gym','money','cash','laptop','office','travel',
    'food','car','marketing','business','saas','ai','technology'
];

usort($keywords, function($a, $b) use ($visual_words) {
    $a_score = in_array($a, $visual_words) ? 1 : 0;
    $b_score = in_array($b, $visual_words) ? 1 : 0;
    return $b_score - $a_score;
});

$queries = [];

// Attempt 1: best 2–3 keywords
if (count($keywords) >= 3) {
    $queries[] = implode(' ', array_slice($keywords, 0, 3));
} elseif (count($keywords) >= 2) {
    $queries[] = implode(' ', array_slice($keywords, 0, 2));
}

// Attempt 2: best single keyword
if (!empty($keywords)) {
    $queries[] = $keywords[0];
}

// Attempt 3: fallback
$queries[] = "technology";

$image_url = null;

foreach ($queries as $q) {

    $query = urlencode($q);
    echo "Trying query: {$q}\n";

    $page = rand(1, 10);

    $api_url = "https://api.unsplash.com/search/photos?query={$query}&per_page=1&page={$page}&orientation=landscape&client_id={$access_key}";

    $response = wp_remote_get($api_url);

    if (is_wp_error($response)) {
        continue;
    }

    $body = json_decode(wp_remote_retrieve_body($response), true);

    if (!empty($body['results'][0]['urls']['regular'])) {
        $image_url = $body['results'][0]['urls']['regular'];
        echo "Found image with query: {$q}\n";
        break;
    }
}

if (!$image_url) {
    echo "ERROR: No image found at all\n";
    continue;
}
       
        echo "Image URL OK\n";

       $tries = 0;
$image_response = false;

while ($tries < 2) {

    $image_response = wp_remote_get($image_url, [
        'timeout' => 20,
        'redirection' => 5,
        'user-agent' => 'Mozilla/5.0'
    ]);

    if (!is_wp_error($image_response)) {
        break;
    }

    $tries++;
}

if (is_wp_error($image_response)) {
    echo "ERROR: Download failed after retry\n";
    continue;
}

$image_data = wp_remote_retrieve_body($image_response);

if (!$image_data) {
    echo "ERROR: Empty image data\n";
    continue;
}

        $upload_dir = wp_upload_dir();

        if (empty($upload_dir['path'])) {
            echo "ERROR: Upload path issue\n";
            continue;
        }

        $filename = 'unsplash-' . time() . '-' . $post->ID . '.jpg';
        $file = trailingslashit($upload_dir['path']) . $filename;

        file_put_contents($file, $image_data);

        if (!file_exists($file)) {
            echo "ERROR: File write failed\n";
            continue;
        }

        $filetype = wp_check_filetype($filename, null);

        $attachment = [
            'post_mime_type' => $filetype['type'],
            'post_title'     => sanitize_text_field($title),
            'post_status'    => 'inherit'
        ];

        $attach_id = wp_insert_attachment($attachment, $file, $post->ID);

        if (is_wp_error($attach_id)) {
            echo "ERROR: Attachment failed\n";
            continue;
        }

        $attach_data = wp_generate_attachment_metadata($attach_id, $file);
        wp_update_attachment_metadata($attach_id, $attach_data);

        set_post_thumbnail($post->ID, $attach_id);

        echo "SUCCESS\n";
    }

    echo "\nDONE.\n
"; exit; });

FO Talks: The Collapse of New START Treaty Raises Global Nuclear Risks

TDY News

Editor-in-Chief Atul Singh and Simon Cleobury, Head of Arms Control and Disarmament at the Geneva Centre for Security Policy, discuss the expiration of the New Strategic Arms Reduction Treaty (New START) and what its disappearance means for global nuclear stability. With the last major US–Russia arms control agreement gone, are the world’s nuclear guardrails disappearing? Singh and Cleobury examine how New START functioned, why it mattered and why rebuilding trust among nuclear powers will now be far more difficult. They also explore the roles of China, France and the United Kingdom in a shifting nuclear landscape shaped by geopolitical rivalry and declining cooperation.

What New START achieved

Cleobury begins by explaining that New START placed limits on the number of deployed strategic nuclear warheads, missiles and launchers held by the United States and Russia. These “strategic” weapons are designed to target infrastructure and population centers, making them central to deterrence. By capping these arsenals, the treaty helped maintain balance and prevented either side from seeking overwhelming superiority.

Equally important were the treaty’s verification mechanisms. These included data exchanges, notifications, inspections and regular consultations. These measures are essential for reducing uncertainty. “It gave an element of predictability and certainty,” Cleobury explains; transparency lowered the risk of miscalculation. Without such mechanisms, each side must rely more heavily on assumptions about the other’s capabilities, increasing the chance of suspicion and escalation.

The treaty’s structure also reflected practical constraints. Reducing nuclear arsenals takes time, technical effort and financial resources. The seven-year implementation period ensured neither side gained a temporary advantage while reductions were underway. This gradual process reinforced stability and maintained deterrence while cuts were completed.

A world without constraints

With New START’s expiration, those formal limits are gone. Cleobury cautions that this does not automatically trigger an arms race. Building new nuclear capabilities requires time and investment. Yet the psychological shift may be more consequential than immediate force expansion. “The guardrails are off,” he warns, noting that uncertainty can alter planning even before weapons numbers change.

Without inspections or data exchanges, military planners may assume the worst. If leaders believe the other side is secretly expanding its arsenal, they may respond by strengthening their own. This dynamic creates a classic security dilemma. Even absent hostile intent, fear and suspicion can drive competitive buildup.

Singh places this development in the context of today’s geopolitical tensions, highlighting the Russia–Ukraine war and conflict in the Middle East. Cleobury agrees that the current environment differs sharply from the one in which New START was negotiated. Trust between Washington and Moscow has deteriorated, making future agreements more difficult to achieve.

Trust collapse and negotiation barriers

Both sides now question the reliability of the other. In Washington, Russia is widely viewed as an aggressive power that violated international norms in Ukraine. In Moscow, US military support for Kyiv fuels suspicion that Washington is engaged in a proxy conflict. This mutual distrust complicates arms control discussions that once proceeded despite broader disagreements.

Cleobury notes that US policymakers also seek a broader agreement covering tactical nuclear weapons and emerging technologies, such as hypersonic missiles. In addition, Washington wants China included in any future arrangement. These expanded goals increase complexity and reduce the likelihood of quick progress.

Despite these obstacles, leadership at the highest level could still make a difference. Cleobury argues that political will is essential, especially from US President Donald Trump and Russian President Vladimir Putin. “If any progress is to be made here, then Putin and Trump are absolutely key,” he says, pointing to the importance of top-level engagement in nuclear decision-making.

China, France and a changing nuclear landscape

China’s role further complicates the picture. Beijing maintains that its arsenal is far smaller than those of the US and Russia and therefore sees bilateral reductions between the two superpowers as the priority. China also lacks the long tradition of arms control negotiations that shaped Cold War diplomacy, making engagement more challenging.

Meanwhile, France’s recent signals about increasing its nuclear stockpile and reducing transparency add another layer of complexity. Such moves reinforce perceptions of competition among nuclear powers and strengthen calls for broader multilateral discussions. Yet expanding negotiations to include multiple states makes agreement harder to reach.

Cleobury suggests that a leaders summit of the five nuclear-armed permanent members of the UN Security Council could help restart dialogue. Even limited discussions on transparency or risk reduction might rebuild some confidence. He emphasizes that arms control can function not only as a reward for improved relations, but also as a tool to reduce tensions.

An uncertain future for arms control

Singh and Cleobury conclude that the world is entering a period with fewer formal constraints on nuclear competition. The absence of New START removes a key mechanism for managing rivalry between the largest nuclear powers. Replacing it will require political leadership, renewed trust and willingness to engage despite ongoing conflicts.

Cleobury warns that without such efforts, the world may face a prolonged gap in arms control agreements. “Without that political direction … we’re in for quite a long period without any arms control agreements,” he says.

While the risks are growing, dialogue remains possible if leaders choose to pursue it.

[Lee Thompson-Kolar edited this piece.]

The views expressed in this article/video are the author’s own and do not necessarily reflect Fair Observer’s editorial policy.

The post FO Talks: The Collapse of New START Treaty Raises Global Nuclear Risks appeared first on Fair Observer.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Share post:

Subscribe

spot_img

Popular

More like this
Related

How Hybrid Warfare Shaped the Iran War Before It Began

On February 28, before the first explosion was visible...

Why Northeast India Remains Neglected and How to Fix It

When Lakshmipriya Devi took the stage at the recent...

Bangladesh Nationalist Party Declares Victory in Pivotal Election

In Dhaka, the Bangladesh Nationalist Party claimed what party...

NATO Presses Members to Boost Defense Spending Amid Renewed Security Concerns

Leaders of NATO concluded a high stakes summit in...