Version eines WordPress-Plugins abfragen

Um die Version eines WordPress-Plugins abzufragen, kann man folgenden Code nutzen:

$plugin_to_look_for = 'Formidable';
$all_plugins        = get_plugins();

$count = 0;

foreach ( array_keys( $all_plugins ) as $key_name ) {
    $plugin_name = $all_plugins[ $key_name ]['Name'];
    $plugin_file = $key_name;


    if ( strpos( $plugin_name, $plugin_to_look_for ) !== false ) {
        $count          = $count + 1;
        $plugin_version = $all_plugins[ $key_name ]['Version'];
        echo sprintf( "%s | %s<br />", $all_plugins[ $key_name ]['Name'], $plugin_version );
    }
}

if ( $count == 0 ) {
    echo "Plugin is not installed";
}

Schreibe einen Kommentar