Skip to content

Updates of Themes and Plugins via WP-Toolkit / WP CLI #575

@Cryptoom

Description

@Cryptoom

I have integrated the plugin updater and it works fine when I go to the admin panel and click on "Updates", then the updates are displayed immediately.

If I try to trigger the whole thing via WP-Toolkit CLi or search for updates via Plesk, nothing is displayed.

I have integrated it into the theme as an example.

// Updater Class
require get_stylesheet_directory() . '/plugin-update-checker/plugin-update-checker.php';
$themeDirectory = get_stylesheet_directory(); // Or get_stylesheet_directory() for child themes
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;

// Theme updater
$mylandingpageUpdater = PucFactory::buildUpdateChecker(
    'https://api.mydemoupdater.ai/updater/landingpageai-theme.json',
    $themeDirectory, // Use the path to the root of the theme
    'landingpageai-child'
);

I have already tried an update script via PHP which I trigger via CLI.

<?php
// request-update.php

// Authentication
require_once(dirname(__FILE__) . '/sync_key-521A1-245-4.php'); // Loads the file that defines the key
if (!defined('SYNC_KEY') || !isset($_GET['key']) || $_GET['key'] !== SYNC_KEY) {
    http_response_code(403);
    the('Access denied');
}

// Determine the path to wp-load.php
$wp_load_path = dirname(__FILE__, 5) . '/wp-load.php';
if (!file_exists($wp_load_path)) {
    http_response_code(500);
    the('wp-load.php not found');
}

require($wp_load_path);


// Perform updates
function perform_updates() {
    wp_update_themes();
    wp_update_plugins();
    wp_version_check(array(), true);
    wp_maybe_auto_update();
}

wp_clean_update_cache();

// Perform updates
perform_updates();
?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions