What are the details for function argument wp_update_plugin()

While looking at wp_update_plugin() function.

function wp_update_plugin($plugin, $feedback = '') {
    if ( !empty($feedback) )
        add_filter('update_feedback', $feedback);

    include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $upgrader = new Plugin_Upgrader();
    return $upgrader->upgrade($plugin);
}

Its very hard to know what data type I should send as first argument $plugin. Is it the plugin name, file name or object?

Read More

Also the second argument $feedback. What is the purpose of it?

Related posts

1 comment

  1. The first argument is the plug-in’s ‘slug’. The plug-in slug is determined by the location of the .php file header containing the comment header necessary for plug-ins. (see source).

    If your main plug-in file might be ~/wp-content/plugins/foo/bar.php, while your plug-in slug is foo/bar.php.

    If the wp-content dir has a custom name, you can retrieve it using content_url( $path ), where $path is any trailingslashed single suffix like the plugins directory. Keep in mind that at the end of the function there is a filter, so you better check if something modified it. Then there’s plugins_url( $path, $plugin ) and so on. So you better make sure you got the right path that takes the different possible locations into account.

    The second argument is a callback which will be hooked onto update_feedback filter. This only appears to be used in update-core.php (source)). I believe this can be used to force flush the output so the user gets some kind of feedback – but I’m not sure where (or if) core does this.

Comments are closed.