a8cteam51 / safety-net

Scrub options, deactivate denylisted plugins, and delete user data on development sites.
17 stars 1 forks source link

Disable Publicize #48

Closed GeoJunkie closed 1 year ago

GeoJunkie commented 1 year ago

We should disable publicize on dev sites. Keeping it enabled runs the risk of accidentally sharing development content on partner's social media accounts.

Slack conversation that led to this issue

We should be able to do this using the jetpack_deactivate_module hook

NickGreen commented 1 year ago

That hook fires after a module is disabled.

It might be possible to use the Module_Control class to deactivate the module, such as https://github.com/Automattic/jetpack-production/blob/75e96a4c2c1713ba3981d44f29b9f3d835bb39b5/jetpack_vendor/automattic/jetpack-search/src/class-module-control.php#L104

However, what I would suggest, in this case, would be to change the jetpack_active_modules option directly. That way it will be deactivated more silently, and not trigger anything that's hooked into the module deactivation. Such as:

  1. Add jetpack_active_modules to this array: https://github.com/a8cteam51/safety-net/blob/e00ef0773c3e647ed9d54b8d6ee53bd8d80b50d0/includes/deactivate-plugins.php#L63
  2. Add a new elseif to this block: https://github.com/a8cteam51/safety-net/blob/e00ef0773c3e647ed9d54b8d6ee53bd8d80b50d0/includes/deactivate-plugins.php#L71-L83
  3. check if the option is jetpack_active_modules, which will contains vaules like this:
array (
  0 => 'contact-form',
  1 => 'enhanced-distribution',
  2 => 'json-api',
  3 => 'notes',
  4 => 'protect',
  5 => 'stats',
  6 => 'verification-tools',
  7 => 'woocommerce-analytics',
  8 => 'monitor',
  9 => 'sso',
  10 => 'search',
  11 => 'seo-tools',
  12 => 'sitemaps',
  13 => 'publicize',
)
  1. Delete the publicize value and re-save the option.

@bernattorras Since we are doing the Safety Net task force async this week, this would be a good one for you to tackle during that hour. Let me know if you don't have time to take this on.

NickGreen commented 1 year ago

Fix merged. closing issue. Nice work, @bernattorras !