Skip to content

Commit

Permalink
Merge pull request #1 from sterner-stuff/composer-json
Browse files Browse the repository at this point in the history
Remove plugin scaffolding. CLI command only.
  • Loading branch information
ethanclevenger91 authored Aug 19, 2021
2 parents 52c1a22 + 142ba31 commit 3591224
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 81 deletions.
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,18 @@ Clears all cached files to force Cloudflare to fetch a fresh version of those fi

## Installing

This package depends on the `\CF\WordPress\Hooks` class from the [Cloudflare for WordPress](https://wordpress.org/plugins/cloudflare/) plugin. Make sure this one is installed and active first.
This package depends on the `\CF\WordPress\Hooks` class from the [Cloudflare for WordPress](https://wordpress.org/plugins/cloudflare/) plugin. Make sure it is installed and active.

1. Download or clone the contents of this repo.
2. Place the “cloudflare-cli” folder to your “/wp-content/plugins/” directory.
3. Activate Cloudflare CLI Add-On from your Plugins page.

##### Using Composer

1. Add this GitHub repo to the _"repositories"_ key in your project's `composer.json` file.
### Via WP-CLI

```
composer config repositories.forumone '{ "type": "package", "package": { "name": "forumone/cloudflare-cli", "version": "dev-master", "type": "wordpress-plugin", "dist": { "type": "zip", "url": "https://github.com/forumone/cloudflare-cli/archive/master.zip" }, "require": { "composer/installers": "^1.0" } } }'
```bash
wp package install https://github.com/sterner-stuff/cloudflare-cli
```

2. Require the plugin package to your project.
~~~
composer require forumone/cloudflare-cli:dev-master
~~~

3. Activate Cloudflare CLI Add-On from your Plugins page.
### Using Composer

```bash
composer config repositories.cloudflare-cli '{ "type": "vcs", "url": "[email protected]:sterner-stuff/cloudflare-cli.git" }'
composer require sterner-stuff/cloudflare-cli
```

65 changes: 2 additions & 63 deletions cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,8 @@
/**
* Cloudflare CLI Add-On
*
* @package PluginPackage
*
* Plugin Name: Cloudflare CLI Add-On
* Plugin URI: https://github.com/forumone/cloudflare-cli
* Description: Purge all Cloudflare cache from WP-CLI.
* Author: Forum One
* Version: 1.0.0
* Author URI: https://www.forumone.com/
* License: GPLv3
*/

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* The plugin initializer class.
*/
class F1_Cloudflare_CLI_Core {

/**
* Plugin instance.
*
* @var object $instance
*/
private static $instance;

/**
* Etc etc
*/
public function __construct() {
define( 'F1_CLOUDFLARE_CLI_DIR', dirname( __FILE__ ) );
// WP is loaded.
add_action( 'init', array( $this, 'init' ), 1 );
}

/**
* Initialize the singleton
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}

/**
* Initialize classes and WP hooks
*/
public function init() {
// WP-CLI.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
include( F1_CLOUDFLARE_CLI_DIR . '/includes/class-cloudflare-wp-cli.php' );
}
}

}

/**
* Initilize plugin instance.
*/
function f1_cloudflare_cli() {
return F1_Cloudflare_CLI_Core::instance();
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require ( 'includes/class-cloudflare-wp-cli.php' );
}
f1_cloudflare_cli();
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "sterner-stuff/cloudflare-cli",
"type": "wp-cli-package",
"description": "Provides a command line interface to the WordPress Cloudflare plugin, for performing cache purge actions.",
"license": "GPLv2 or later",
"require": {
"php": ">=7.2"
},
"authors": [
{
"name": "Elvis Morales",
"homepage": "https://elvismdev.io"
},
{
"name": "Ethan Clevenger",
"email": "[email protected]",
"homepage": "https://sternerstuff.dev"
}
],
"support": {
"issues": "https://github.com/sterner-stuff/cloudflare-cli/issues",
"source": "https://github.com/sterner-stuff/cloudflare-cli"
},
"autoload": {
"files": [ "cli.php" ]
}
}
2 changes: 0 additions & 2 deletions index.php

This file was deleted.

0 comments on commit 3591224

Please sign in to comment.