An open API service indexing awesome lists of open source software.

https://github.com/robertdevore/wpcom-check

A utility to handle WordPress.com-specific plugin compatibility and auto-deactivation.
https://github.com/robertdevore/wpcom-check

Last synced: 10 months ago
JSON representation

A utility to handle WordPress.com-specific plugin compatibility and auto-deactivation.

Awesome Lists containing this project

README

          

# WPCom Check

WPCom Check is a WordPress® utility designed to ensure compatibility with WordPress.com-hosted environments.

It provides automated plugin deactivation and user notifications if a plugin is not supported on WordPress.com.

This tool is ideal for plugin developers who want to ensure their plugins gracefully handle unsupported hosting environments.

## Features

- Automatically detects if the site is hosted on WordPress.com.
- Deactivates the plugin if unsupported.
- Displays an admin notice with information about the deactivation.
- Prevents activation on unsupported environments.
- Allows developers to provide a custom learn-more link for user education.

## Installation

### Using Composer

Add the package to your project:

```
composer require robertdevore/wpcom-check
```

Include Composer's autoload file in your plugin or theme:

```
if ( ! class_exists( 'RobertDevore\WPComCheck\WPComPluginHandler' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
```

Instantiate the `WPComPluginHandler` class in your plugin's main file:

```
use RobertDevore\WPComCheck\WPComPluginHandler;

new WPComPluginHandler( plugin_basename( __FILE__ ), 'https://domain.com/learn-more/' );
```

### Manual Installation

Clone or download the repository from GitHub:

```
git clone https://github.com/robertdevore/wpcom-check.git
```

Include the `WPComPluginHandler.php` file in your project:

```
if ( ! class_exists( 'RobertDevore\WPComCheck\WPComPluginHandler' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
```

Instantiate the class in your plugin's main file:

```
use RobertDevore\WPComCheck\WPComPluginHandler;

new WPComPluginHandler( plugin_basename( __FILE__ ), 'https://domain.com/learn-more/' );
```

## Usage

### Parameters

- `**$pluginSlug**`: (string) The plugin slug, typically obtained using `plugin_basename(__FILE__)`.
- `**$learnMoreLink**`: (string) A URL pointing to more information about the deactivation reason or alternative solutions.

### Example

Here is how to use WPCom Check in your plugin:
```