WordPress HTTP API replacement of the jamesryanbell/cloudflare package.
- Why use WP HTTP APIinstead ofcurl?
- Install
- Usage
- Start Developing
- Running the Tests
- Feedback
- Change log
- Contributing
- Security
- Credits
- License
curl is great. However, it is not always available on every hosts, especially shared hosting.
Using WordPress HTTP API lets WordPress figure out the best way to make HTTP requests.
It could be curl or something else. You don't need to care about it. See WordPress codex.
Installation should be done via composer, details of how to install composer can be found at https://getcomposer.org/.
$ composer require typisttech/cloudflare-wp-apiSince the jamesryanbell/cloudflare package doesn't provide a way to inject client objects,
we have to rename Cloudflare\Api to Cloudflare\BaseApi. And, use our Api class instead
$ vendor/bin/cfwp buildYou have to run the command on every composer install and composer update.
A better way to do so is to add this command to composer.json like so:
  "scripts": {
    "post-install-cmd": "cfwp build",
    "post-update-cmd": "cfwp build"
  }Once $ cfwp build is done, you can use it exactly the same as the original package.
See jamesryanbell/cloudflare for more details about the original package.
Decode body array from wp_remote_request.
WP_Error object. Maybe returned from wp_remote_request, or one of the followings:
| Code | Message | Data | 
|---|---|---|
| authentication-error | Authentication information must be provided | |
| authentication-error | Email is not valid | |
| decode-error | Response errors is not an array | response | 
Or, one of the Coudlfare defined error codes, here is some example:
| Code | Message | Data | 
|---|---|---|
| 1012 | Request must contain one of 'purge_everything' or 'files' | response | 
| 1210 | That operation is no longer allowed for that domain | response | 
This command will clone the project source code from GitHub and install its dependencies.
$ composer create-project --no-install --prefer-source --keep-vcs typisttech/cloudflare-wp-api:dev-master
$ cd cloudflare-wp-api
$ composer installCloudflare WP API run tests on Codeception and relies wp-browser to provide WordPress integration. Before testing, you have to install WordPress locally and add a codeception.yml file. See codeception.example.yml for a Varying Vagrant Vagrants configuration example.
Actually run the tests:
$ composer testWe also test all PHP files against PSR-2: Coding Style Guide and part of the WordPress coding standard.
Check the code style with $ composer check-style and fix it with $ composer fix-style.
Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email cloudflare-wp-api@typist.tech instead of using the issue tracker.
Please see CONTRIBUTING and CONDUCT for details.
Cloudflare WP API is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.
Full list of contributors can be found here.
Special thanks to James Bell whose Cloudflare package make this project possible.
Cloudflare WP API is licensed under the GPLv2 (or later) from the Free Software Foundation. Please see License File for more information.
