1

I have the paid Divi theme on many websites on a cPanel powered server. I use WP-CLI in a bash script to update all the plugins and themes. But Divi will never update because it only reveals an update is available when you visit wp-admin/update-core.php When you visit that main update page with a browser, you'll see the update number next to "Updates" magically grow by +1.

What I want to do is call update-core.php so it runs one time, because after that happens, WP-CLI is able to detect the Divi update without any problem. At least this is what I think I want to do. Clearly I'm open to suggestions.

What I've tried so far:

This is the php script in the public web root:

<?php
define( 'WP_ADMIN', true );
ignore_user_abort(true);
$path = $_SERVER['DOCUMENT_ROOT'];
//define( 'SHORTINIT', true );
require( $path.'/wp-load.php' );
require( $path.'/wp-admin/update-core.php' );

But calling that from a browser just goes to a login screen, because it fails the current_user_can checks at the beginning of update-core.php Should I try to create a hacked version of update-core.php that has no user checks? Am I pursuing the wrong path entirely?

There was a discussion on GitHub but I was not able to get the --require feature to work with a script containing define( 'WP_ADMIN', true );

https://github.com/wp-cli/extension-command/issues/106

The bash script I use to bulk update is like this--

#!/bin/bash

declare -a arr=(
"account1"
"account2"
"account3"
                )

for i in "${arr[@]}"
do
   echo "$i"
   echo ______________________________________________________
   cd /home/"$i"/www
   wp core update-db --allow-root
   wp core update --allow-root
   wp plugin update --all --allow-root
   wp theme update --all --allow-root
   chown -R "$i":"$i" *
done
1
  • 1
    I'd guess Divi has its own way of doing an update detection, separate from wp_update_themes, that gets triggered by update-core somehow. I'd read the theme code to work out what that is and trigger it directly rather than trying to load the update-core page. I'd guess it adds itself to the 'update_themes' site transient when there is an update so you could start by searching for that string.
    – Rup
    Commented Aug 28, 2019 at 23:37

1 Answer 1

0

WP-CLI was updated to include a new global parameter that allows the execution of arbitrary PHP code before the main command runs. This allows you to pass the is_admin() check that some themes and plugins use.

wp plugin update --all --exec="define( 'WP_ADMIN', true );"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.