geminilabs

[site-reviews] fix install error (directory exists)

Apr 26th, 2020
224
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * WordPress automatic updates can sometimes fail when updating a plugin. Common reasons are server timeouts,
  3.  * permission issues, or a plugin script is still in use when WordPress attempts to delete the plugin. When
  4.  * this happens, you may be left with an empty plugin folder which makes it impossible to reinstall the
  5.  * plugin (since the plugin folder still exists).
  6.  *
  7.  * If this has happened to you with Site Reviews, then this snippet will tell WordPress to delete the
  8.  * "site-reviews" folder from your plugins directory when installing the plugin.
  9.  *
  10.  * !! IMPORTANT !! Please remove or disable this snippet once you have finished reinstalling Site Reviews.
  11.  *
  12.  * @param array $options
  13.  * @return array
  14.  */
  15. add_filter('upgrader_package_options', function ($options) {
  16.     $options = wp_parse_args((array) $options, ['package' => '']);
  17.     if (false !== strpos($options['package'], '/plugin/site-reviews.')) {
  18.         $options['clear_destination'] = true;
  19.     }
  20.     return $options;
  21. });
RAW Paste Data Copied