slug = $slug; } /** * Get the plugin slug. * * @return string */ public function get_slug() { return $this->slug; } /** * Add the plugin connection info into Jetpack. * * @param string $name Plugin name, required. * @param array $args Plugin arguments, optional. * * @return $this * @see $this->arguments_whitelist */ public function add( $name, array $args = array() ) { $args = compact( 'name' ) + array_intersect_key( $args, array_flip( $this->arguments_whitelist ) ); Plugin_Storage::upsert( $this->slug, $args ); return $this; } /** * Remove the plugin connection info from Jetpack. * * @return $this */ public function remove() { Plugin_Storage::delete( $this->slug ); return $this; } /** * Determine if this plugin connection is the only one active at the moment, if any. * * @return bool */ public function is_only() { $plugins = Plugin_Storage::get_all( true ); return ! $plugins || ( array_key_exists( $this->slug, $plugins ) && 1 === count( $plugins ) ); } /** * Add the plugin to the set of disconnected ones. * * @return bool */ public function disable() { return Plugin_Storage::disable_plugin( $this->slug ); } /** * Remove the plugin from the set of disconnected ones. * * @return bool */ public function enable() { return Plugin_Storage::enable_plugin( $this->slug ); } /** * Whether this plugin is allowed to use the connection. * * @return bool */ public function is_enabled() { return ! in_array( $this->slug, Plugin_Storage::get_all_disabled_plugins(), true ); } }