0

i need to get a list of all updates the wp site need (core, plugin and themes). i already know about wp_get_update_data(), but it give me back only the number. i need to get for example:

plugin1 | actual version | new version

plugin2 | actual version | new version

theme1 | actual version | new version

wp | actual version | new version

how can i save that information into some arrays to use them?

edit: i managed to do this with what i found but it doesn't work, it print to try only test

function data_report()
{
    // Get theme info
    $theme_data = wp_get_theme();
    $theme = $theme_data->Name . ' ' . $theme_data->Version;

    // Get plugins that have an update
    $updates = get_plugin_updates();

    // WordPress active plugins
    $fin_plug = "\n" . '-- WordPress Active Plugins' . "\n\n";
    $plugins = get_plugins();
    $active_plugins = get_option('active_plugins', array());
    foreach ($plugins as $plugin_path => $plugin) {
        if (!in_array($plugin_path, $active_plugins)) {
            continue;
        }
        $update = array_key_exists($plugin_path, $updates) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
        $fin_plug .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
    }

}


add_action( 'wp_footer', 'stampa_prova' );

function stampa_prova (){   
        echo 'test';
        $cospi = data_report();
        echo $cospi;
}
1

When on the admin view you can use the following functions to get update data.

If you want to build your own functions, then you can get update related data from site transients update_themes, update_plugins, and update_core. Then you can compare the plugin and theme transients with the theme and plugin arrays you can get with wp_get_themes() and get_plugins(). The above functions are more or less wrappers for these transients and functions.

Have a look at the source for the functions to see how WP handles this stuff.

  • i tried to use the 3 function u linked, but they don' t give me anything back – DevBeppe Feb 6 at 14:40
0

solved, if someone need the code i posted work, need only to add the admin permission to execute with require_once

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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