• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question How to set defaults for WP Toolkit "Updates Settings"

gbotica

Regular Pleskian
Server operating system version
AlmaLinux 8.7
Plesk version and microupdate number
Version 18.0.50 Update #2
Hi there,

I can't seem to find anyway of setting / forcing default settings for the WP Toolkit "Updates Settings".

Everytime a new WP instance is installed or registered with WP Toolkit, the WordPress Updates Settings always default to "No Change" for WP Core, plugins and themes.
I want to force the defaults to be:

"Yes, but only minor (security) updates" for WP Core and
"Defined individually, but security updates are autoinstalled" for plugins and themes

Is this possible somehow?

At the moment, I need to periodically go to WP Toolkit -> Updates -> Change Settings -> OK, to apply the settings to all sites.

It's fine for customers to be able to change this later, but by default I would prefer the above settings be applied, and as far as I can see, this isn't currently possible.
 
This feature needs yet to be added. If you believe it is important, please vote for it here:
 
This feature needs yet to be added. If you believe it is important, please vote for it here:
OK, will do. Thank you for letting me know.
 
To enable automatic plugin and theme updates in Plesk:

Create a file called /usr/local/psa/bin/auto_updates_wordpress.sh

Code:
for domain in $(plesk ext wp-toolkit --list | grep "${NEW_DOMAIN_NAME}" | awk {'print $1'}); do
    plesk ext wp-toolkit --wp-cli -instance-id $domain -- plugin auto-updates enable --all
    plesk ext wp-toolkit --wp-cli -instance-id $domain -- theme auto-updates enable --all
done

In Plesk Add an Event Handler
Event: WordPress installed
Command: /usr/local/psa/bin/auto_updates_wordpress.sh
 
The above solution is far from perfect. It only works for currently installed plugins and themes.
So quite pointless.

I'm going to dig further to see how we can influence "Autoupdate all plugins" and "Autoupdate all themes" via CLI.

Scherm­afbeelding 2023-04-05 om 20.03.55.png
 
@Mark_SQR The scsript itself is only for existing installations, but the idea is to add an event "Wordpress installed" which triggers to run the script. So everytime a new Wordpress is installed, the script is executed and will set the update settings to what is defined in the script.
 
I know, I wrote it ;-)

Does anyone know where in the database Plesk stores the "Autoupdate all plugins" and "Autoupdate all themes" settings?
 
I don't know how and where WTP saves the update settings. However, if you want to create a script that alters the update settings for a newly created WP install the Plesk REST API for WPT might be useful. The /v1/features/updates/settings endpoint look particularly promising for this. Now, I haven't used the REST API for WPT myself, so I am not 100% sure if this will actually help you accomplish your goal. But it looks promising.
 
Allright , thank you very much @Kaspar !

Update Settings.png

To enable automatic core, plugin and theme updates in Plesk:
  1. Get a API Key and at step 2 replace YOURAPIKEY: plesk bin secret_key -c
  2. Create a file called /usr/local/psa/bin/auto_updates_wordpress.sh with the following content:
    Code:
    # Don't work to quick
    sleep 5
    # Get the WordPress ID
    for id in $(plesk ext wp-toolkit --list | grep "${NEW_DOMAIN_NAME}" | awk {'print $1'}); do
    # Change update settings
    echo "Changing WP Toolkit auto update settings for WP id" $id >> /tmp/log.txt
    curl -kX 'POST' \
      'https://[redacted]/api/modules/wp-toolkit/v1/features/updates/settings' \
      -H 'accept: application/json' \
      -H 'X-API-Key: YOURAPIKEY' \
      -H 'Content-Type: application/json' \
      -d '{
      "installationsIds": ['$id'],
      "autoUpdate": {
        "core": "major",
        "plugins": {
          "forceUpdates": false,
          "newlyInstalledUpdates": true,
          "updateVulnerable": true,
          "deactivateVulnerable": false
        },
        "themes": {
          "forceUpdates": false,
          "newlyInstalledUpdates": true,
          "updateVulnerable": true
        }
      }
    }' >> /tmp/log.txt
    done
  3. execute the command: chmod +x /usr/local/psa/bin/auto_updates_wordpress.sh
  4. In Plesk Add an Event Handler
    Event: WordPress installed
    Command: /usr/local/psa/bin/auto_updates_wordpress.sh
 
Last edited by a moderator:
Some improvements on the above script (can't edit post..):
  • added hostname variable to be easily deployable to multiple servers
  • added better logging
Bash:
# Don't work to quick
sleep 5
# Set some variables
hostname=`hostname`
# Get the WordPress ID
for id in $(plesk ext wp-toolkit --list | grep "${NEW_DOMAIN_NAME}" | awk {'print $1'}); do
# Change update settings
echo "Changing WP Toolkit auto update settings for WP id" $id >> /tmp/log.txt
curl -sSkX 'POST' \
  "https://$hostname:8443/api/modules/wp-toolkit/v1/features/updates/settings" \
  -H 'accept: application/json' \
  -H 'X-API-Key: 343d4ab5-5c80-e42e-3504-21fd09ae734e' \
  -H 'Content-Type: application/json' \
  -d '{
  "installationsIds": ['$id'],
  "autoUpdate": {
    "core": "major",
    "plugins": {
      "forceUpdates": false,
      "newlyInstalledUpdates": true,
      "updateVulnerable": true,
      "deactivateVulnerable": false
    },
    "themes": {
      "forceUpdates": false,
      "newlyInstalledUpdates": true,
      "updateVulnerable": true
    }
  }
}' >> /tmp/log.txt 2>&1
done
 
Some improvements on the above script (can't edit post..):
  • added hostname variable to be easily deployable to multiple servers
  • added better logging
Bash:
# Don't work to quick
sleep 5
# Set some variables
hostname=`hostname`
# Get the WordPress ID
for id in $(plesk ext wp-toolkit --list | grep "${NEW_DOMAIN_NAME}" | awk {'print $1'}); do
# Change update settings
echo "Changing WP Toolkit auto update settings for WP id" $id >> /tmp/log.txt
curl -sSkX 'POST' \
  "https://$hostname:8443/api/modules/wp-toolkit/v1/features/updates/settings" \
  -H 'accept: application/json' \
  -H 'X-API-Key: 343d4ab5-5c80-e42e-3504-21fd09ae734e' \
  -H 'Content-Type: application/json' \
  -d '{
  "installationsIds": ['$id'],
  "autoUpdate": {
    "core": "major",
    "plugins": {
      "forceUpdates": false,
      "newlyInstalledUpdates": true,
      "updateVulnerable": true,
      "deactivateVulnerable": false
    },
    "themes": {
      "forceUpdates": false,
      "newlyInstalledUpdates": true,
      "updateVulnerable": true
    }
  }
}' >> /tmp/log.txt 2>&1
done
Just a heads up - you're API key is included in the script! Hopefully you've changed it otherwise anyone can access your Plesk installation
 
@gbotica Hey Gavin, we definitely want to add this to WP Toolkit, it's just a question of finding enough time and resources to fit this in-between the bigger stuff. I have to admit this feature has almost made it to the scope of several major releases already, but circumstances have pushed it out of final scope every time. Let me see if third time's the charm -- but I wouldn't expect it until Summer in any case.
 
Back
Top