A WordPress API library for accessing the Cloudflare API.

version 1.1.0
link API Documentation
package WP-API-Libraries\WP-IDX-Cloudflare-API
author Santiago Garza
author imFORZA

 Methods

Class constructor.

__construct(string $api_key, string $auth_email, string $user_service_key = ''

Parameters

$api_key

string

Cloudflare API Key.

$auth_email

string

Email associated to the account.

$user_service_key

string

User Service key.

Change a page rule.

change_zone_pagerule(string $id, string $pr_id, array $targets = null, array $actions = null, integer $priority = null, string $status = null) : array
API
api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$pr_id

string

Page rule ID.

$targets

array

Targets to evaluate on a request. See API docs for details.

$actions

array

The set of actions to perform if the targets of this rule match the request. Actions can redirect the url to another url or override settings (but not both).

$priority

integer

A number that indicates the preference for a page rule over another. In the case where you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a higher priority on the latter (#2) so it will override the first. Default: 1.

$status

string

Status of the page rule. Default: disabled. Valid Values: active, disabled.

Returns

arrayPage rule info.

TODO: Complete

connect_zone_railguns() 

Create access rule

create_user_accesss_rule(string $mode, string $config_target, string $config_value, string $notes = '') : array
API

Make a new IP, IP range, or country access rule for all zones owned by the user. Note: If you would like to create an access rule that applies to a specific zone only, use the zone firewall endpoints.

api POST
see Documentation

Parameters

$mode

string

The action to apply to a matched request. Valid values: block, challenge, whitelist.

$config_target

string

Rule configuration target. valid values: ip, ip_range, country.

$config_value

string

Rule configuration value. See API docs for details.

$notes

string

A personal note about the rule. Typically used as a reminder or explanation for the rule.

Returns

arrayNew access rule info.

Create a zone.

create_zone(string $domain, boolean $jump_start = '', array $org = array()) : array
API
api POST
see Documentation

Parameters

$domain

string

The domain name. i.e. "example.com".

$jump_start

boolean

Automatically attempt to fetch existing DNS records.

$org

array

To create a zone owned by an organization, specify the organization parameter. Organization objects can be found in the User or User's Organizations endpoints. You must pass at least the ID of the organization.

Returns

arrayNew zone details.

Create DNS record.

create_zone_dns_record(string $id, string $type, string $name, string $content, integer $ttl = null, boolean $proxied = null) : array
API

Create a new DNS record for a zone. See the record object definitions for required attributes for each record type.

api POST
see Documentation

Parameters

$id

string

Zone ID.

$type

string

DNS record type, i.e "A".

$name

string

DNS record name, i.e "example.com".

$content

string

DNS record content, i.e "127.0.0.1".

$ttl

integer

Time to live for DNS record. Value of 1 is 'automatic'.

$proxied

boolean

Whether the record is receiving the performance and security benefits of Cloudflare.

Returns

arrayThe new DNS record

Create a page rule.

create_zone_pagerules(string $id, array $targets, array $actions, integer $priority = null, string $status = null) : array
API
api POST
see Documentation

Parameters

$id

string

Zone ID.

$targets

array

Targets to evaluate on a request. See API docs for details.

$actions

array

The set of actions to perform if the targets of this rule match the request. Actions can redirect the url to another url or override settings (but not both).

$priority

integer

A number that indicates the preference for a page rule over another. In the case where you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a higher priority on the latter (#2) so it will override the first. Default: 1.

$status

string

Status of the page rule. Default: disabled. Valid Values: active, disabled.

Returns

arrayPage rule info.

Delete access rule.

delete_user_accesss_rule(string $id) : array
API

Remove an access rule so it is no longer evaluated during requests. This will apply to all zones owned by the user.

api DELETE
see Documentation

Parameters

$id

string

Subscription identifier tag.

Returns

arrayArray with deleted access rule ID.

Deletes a user's subscriptions

delete_user_subscriptions(string $subscription_id) : array
API
api DELETE
see Documentation

Parameters

$subscription_id

string

Subscription identifier tag.

Returns

arrayJSON array with deleted subscription ID.

Delete a zone.

delete_zone(string $id) : array
API
api DELETE
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayDeleted zone info.

Delete DNS record.

delete_zone_dns_record(string $id, string $dns_id) : array
API
api DELETE
see Documentation

Parameters

$id

string

Zone ID.

$dns_id

string

DNS record ID.

Returns

arrayArray of results.

Delete a page rule.

delete_zone_pagerule(string $id, string $pr_id) : array
API
api DELETE
see Documentation

Parameters

$id

string

Zone ID.

$pr_id

string

Page rule ID.

Returns

arrayDelted page rule.

Get User Properties

get_user() : array
API

Account Access: FREE, PRO, Business, Enterprise

api GET
see Documentation.
access public

Returns

arrayUser information.

List access rules.

get_user_access_rules(array $args = array()) : array
API

Search, sort, and filter IP/country access rules

api GET
see Documentation

Parameters

$args

array

Array with optional parameters. See API docs for details.

Returns

arrayList of user-level firewall access rules.

Get User Billing History

get_user_billing_history() : array
API
api GET
see Documentation
access public

Returns

arrayUser billing history.

Get User Billing Profile.

get_user_billing_profile() : array
API

Account Access: FREE, PRO, Business, Enterprise

api GET
see Documentation.
access public

Returns

arrayUser billing profile.

Invitation details

get_user_invite_details(string $id) : array
API

Get a specific organization the user is associated with.

api GET
see Documentation

Parameters

$id

string

Invite id.

Returns

arrayArray with invites details.

List invitations

get_user_invites() : array
API

List all invitations associated with my user.

api GET
see Documentation

Returns

arrayList of user invites

Organization details.

get_user_org_details(string $id) : array
API

Get a specific organization the user is associated with.

api GET
see Documentation

Parameters

$id

string

Organization id.

Returns

arrayArray with org details.

List organizations.

get_user_orgs(array $args = array()) : array
API

List organizations the user is associated with.

api GET
see Documentation

Parameters

$args

array

Array with optional parameters. See API docs for details.

Returns

arrayList of user organizations.

Get User Subscriptions.

get_user_subscriptions() : array
API
api GET
see Documentation

Returns

arrayUser subscriptions history.

TODO: Complete

get_zone_analytics_colocations() 

Dashboard.

get_zone_analytics_dashboard(string $id, array $args = array()) : array
API

The dashboard view provides both totals and timeseries data for the given zone and time period across the entire Cloudflare network.

api GET
see Documentation

Parameters

$id

string

Zone ID.

$args

array

Array with optional parameters. See API docs for details.

Returns

arrayList of zone analytics.

Available Rate Plans.

get_zone_available_rate_plans(string $id) : array
API

List all rate plans the zone can subscribe to.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayAvailable rate plan info.

Custom Page details.

get_zone_custom_page_details(string $id, string $page_id) : array
API

Details about a specific Custom page details.

api GET
see Documentation

Parameters

$id

string

Zone ID.

$page_id

string

Custom page ID.

Returns

arrayCustom page info.

Available Custom Pages.

get_zone_custom_pages(string $id) : array
API

A list of available Custom Pages the zone can use.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayArray of custom pages.

DNS Analytics report.

get_zone_dns_analytics(string $id, array $dimensions, array $metrics, string $since, string $until, array $sort = null, array $filters = null, array $limit = null) : array
API

Retrieves a list of summarised aggregate metrics over a given time period.

api GET
see Documentation

Parameters

$id

string

Zone ID.

$dimensions

array

Array of dimensions

$metrics

array

Array of metrics

$since

string

Start date and time of requesting data period in the ISO8601 format

$until

string

End date and time of requesting data period in the ISO8601 format

$sort

array

Array of dimensions to sort by, each dimension may be prefixed by - (descending) or + (ascending)

$filters

array

Segmentation filter in 'attribute operator value' format

$limit

array

Limit number of returned metrics, default is 100

Returns

arrayDNS analytics report.

DNS Analytics by time.

get_zone_dns_analytics_bytime(string $id, array $dimensions = null, array $metrics = null, string $since = null, string $until = null, array $sort = null, array $filters = null, array $limit = null, array $time_delta = null) : array
API

Retrieves a list of aggregate metrics grouped by time interval.

api GET
see Documentation

Parameters

$id

string

Zone ID.

$dimensions

array

Array of dimensions

$metrics

array

Array of metrics

$since

string

Start date and time of requesting data period in the ISO8601 format

$until

string

End date and time of requesting data period in the ISO8601 format

$sort

array

Array of dimensions to sort by, each dimension may be prefixed by - (descending) or + (ascending)

$filters

array

Segmentation filter in 'attribute operator value' format

$limit

array

Limit number of returned metrics, default is 100

$time_delta

array

Unit of time to group data by. Valid values: all, auto, year, quarter, month, week, day, hour, dekaminute, minute.

Returns

arrayDNS analytics report by time.

DNS record details.

get_zone_dns_record_details(string $id, string $dns_id) : array
API

Get details of a single DNS record.

api GET
see Documentation

Parameters

$id

string

Zone ID.

$dns_id

string

DNS record ID.

Returns

arrayArray of DNS record info.

List DNS Records.

get_zone_dns_records(string $id, array $args = array()) : array
API

Search, sort, and filter IP/country access rules.

api GET
see Documentation

Parameters

$id

string

Zone ID.

$args

array

Array with optional parameters. See API docs for details.

Returns

arrayList of DNS records.

Page rule details.

get_zone_pagerule_details(string $id, string $pr_id) : array
API
api GET
see Documentation

Parameters

$id

string

Zone ID.

$pr_id

string

Page rule ID.

Returns

arrayPage rule info.

List page rules.

get_zone_pagerules(string $id, string $status = null, string $order = null, string $direction = null, string $match = null) : array
API
api GET
see Documentation

Parameters

$id

string

Zone ID.

$status

string

Status of the page rule. Default: disabled. Valid values: active, disabled.

$order

string

Field to order page rules by. Default: priority. Valid values: status, priority.

$direction

string

Direction to order page rules. Default: desc. Valid values: asc, desc.

$match

string

Whether to match all search requirements or at least one (any). Default: all. Valid values: any, all.

Returns

arrayList of page rules.

TODO: Complete

get_zone_railgun_details() 

TODO: Complete

get_zone_railguns() 

Get all Zone settings

get_zone_settings(string $id) : array
API

Available settings for your user in relation to a zone

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayZone setting info.

TODO: Complete method.

get_zone_settings_advanced_ddos() 

Get Always Online setting

get_zone_settings_always_online(string $id) : array
API

When enabled, Always Online will serve pages from our cache if your server is offline (https://support.cloudflare.com/hc/en-us/articles/200168006)

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayAlways online setting info.

Get Always Use HTTPS setting

get_zone_settings_always_use_https(string $id) : array
API

Reply to all requests for URLs that use "http" with a 301 redirect to the equivalent "https" URL. If you only want to redirect for a subset of requests, consider creating an "Always use HTTPS" page rule.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayAlways online setting info.

Get Automatic HTTPS Rewrites setting.

get_zone_settings_automatic_https_rewrites(string $id) : array
API

Enable the Automatic HTTPS Rewrites feature for this zone.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayAuto https rewrites setting info.

Get Browser Cache TTL setting.

get_zone_settings_browser_cache_ttl(string $id) : array
API

Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources will remain on your visitors' computers. Cloudflare will honor any larger times specified by your server. (https://support.cloudflare.com/hc/en-us/articles/200168276).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayBrowser cache ttl setting info.

Get Browser Check setting.

get_zone_settings_browser_check(string $id) : array
API

Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page. It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors). (https://support.cloudflare.com/hc/en-us/articles/200170086).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayBrowser check info.

Get Cache Level setting.

get_zone_settings_cache_level(string $id) : array
API

Cache Level functions based off the setting level. The basic setting will cache most static resources (i.e., css, images, and JavaScript). The simplified setting will ignore the query string when delivering a cached resource. The aggressive setting will cache all static resources, including ones with a query string. (https://support.cloudflare.com/hc/en-us/articles/200168256).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayCache level seting info.

Get Challenge TTL setting.

get_zone_settings_challenge_ttl(string $id) : array
API

Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the TTL has expired the visitor will have to complete a new challenge. We recommend a 15 - 45 minute setting and will attempt to honor any setting above 45 minutes. (https://support.cloudflare.com/hc/en-us/articles/200170136).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayChallenge TTL setting info.

Get Development Mode setting.

get_zone_settings_development_mode(string $id) : array
API

Development Mode temporarily allows you to enter development mode for your websites if you need to make changes to your site. This will bypass Cloudflare's accelerated cache and slow down your site, but is useful if you are making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right away. Once entered, development mode will last for 3 hours and then automatically toggle off.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayDevelopment mode setting info.

Get Email Obfuscation setting.

get_zone_settings_email_obfuscation(string $id) : array
API

Encrypt email adresses on your web page from bots, while keeping them visible to humans. (https://support.cloudflare.com/hc/en-us/articles/200170016).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayEmail obfuscation setting info.

Get HTTP2 setting.

get_zone_settings_http2(string $id) : array
API

Value of the HTTP2 setting.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayHTTP2 setting info.

Get IP Geolocation setting.

get_zone_settings_ip_geolocation(string $id) : array
API

Enable IP Geolocation to have Cloudflare geolocate visitors to your website and pass the country code to you. (https://support.cloudflare.com/hc/en-us/articles/200168236).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayHotlink protection setting info.

Get IPv6 setting.

get_zone_settings_ipv6(string $id) : array
API

Enable IPv6 on all subdomains that are Cloudflare enabled. (https://support.cloudflare.com/hc/en-us/articles/200168586).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayIpv6 setting info.

Get Minify setting.

get_zone_settings_minify(string $id) : array
API

Automatically minify certain assets for your website (https://support.cloudflare.com/hc/en-us/articles/200168196).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayMinify setting info.

Get Mirage setting.

get_zone_settings_mirage(string $id) : array
API

Automatically optimize image loading for website visitors on mobile devices (http://blog.cloudflare.com/mirage2-solving-mobile-speed).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayMirage setting info.

Get Mobile Redirect setting.

get_zone_settings_mobile_redirect(string $id) : array
API

Automatically redirect visitors on mobile devices to a mobile-optimized subdomain (https://support.cloudflare.com/hc/en-us/articles/200168336).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayMobile redirect setting info.

Get Opportunistic Encryption setting.

get_zone_settings_opportunistic_encryption(string $id) : array
API

Enable the Opportunistic Encryption feature for this zone.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayOpportunistic encryption setting info.

TODO: Complete.

get_zone_settings_origin_error_page_pass_thru() 

Get Polish setting.

get_zone_settings_polish(string $id) : array
API

Strips metadata and compresses your images for faster page load times. Basic (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster image loading. Larger JPEGs are converted to progressive images, loading a lower-resolution image first and ending in a higher-resolution version. Not recommended for hi-res photography sites.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayPolish setting info.

Get Prefetch Preload setting.

get_zone_settings_prefetch_preload(string $id) : array
API

Cloudflare will prefetch any URLs that are included in the response headers. This is limited to Enterprise Zones.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayPrefetch Preload setting info.

Get pseudo_ipv4 setting.

get_zone_settings_pseudo_ipv4(string $id) : array
API

Value of the pseudo_ipv4 setting.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayPseudo ipv4 setting info.

TODO: Complete.

get_zone_settings_response_buffering() 

Get Rocket Loader setting.

get_zone_settings_rocket_loader(string $id) : array
API

Rocket Loader is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload. Turning on Rocket Loader will immediately improve a web page's window.onload time (assuming there is JavaScript on the page), which can have a positive impact on your Google search ranking. Automatic Mode: Rocket Loader will automatically run on the JavaScript resources on your site, with no configuration required after turning on automatic mode. Manual Mode: In order to have Rocket Loader execute for a particular script, you must add the following attribute to the script tag: "data-cfasync='true'". As your page passes through Cloudflare, we'll enable Rocket Loader for that particular script. All other JavaScript will continue to execute without Cloudflare touching the script. (https://support.cloudflare.com/hc/en-us/articles/200168056).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayRocket Loader setting info.

Get Security Header (HSTS) setting.

get_zone_settings_security_header(string $id) : array
API

Cloudflare security header for a zone.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arraySecurity header setting info.

Get Security Level setting.

get_zone_settings_security_level(string $id) : array
API

Choose the appropriate security profile for your website, which will automatically adjust each of the security settings. If you choose to customize an individual security setting, the profile will become Custom. (https://support.cloudflare.com/hc/en-us/articles/200170056).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arraySecurity level setting info.

Get Server Side Exclude setting.

get_zone_settings_server_side_exclude(string $id) : array
API

If there is sensitive content on your website that you want visible to real visitors, but that you want to hide from suspicious visitors, all you have to do is wrap the content with Cloudflare SSE tags. Wrap any content that you want to be excluded from suspicious visitors in the following SSE tags: . For example: Bad visitors won't see my phone number, 555-555-5555 . Note: SSE only will work with HTML. If you have HTML minification enabled, you won't see the SSE tags in your HTML source when it's served through Cloudflare. SSE will still function in this case, as Cloudflare's HTML minification and SSE functionality occur on-the-fly as the resource moves through our network to the visitor's computer. (https://support.cloudflare.com/hc/en-us/articles/200170036).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayServer side exclude setting info.

TODO: Complete

get_zone_settings_sort_query_string_for_cache() 

Get SSL setting.

get_zone_settings_ssl(string $id) : array
API

SSL encrypts your visitor's connection and safeguards credit card numbers and other personal data to and from your website. SSL can take up to 5 minutes to fully activate. Requires Cloudflare active on your root domain or www domain. Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare and your web server (all HTTP traffic). Flexible: SSL between the visitor and Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and your web server. You don't need to have an SSL cert on your web server, but your vistors will still see the site as being HTTPS enabled. Full: SSL between the visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and your web server. You'll need to have your own SSL cert or self-signed cert at the very least. Full (Strict): SSL between the visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and your web server. You'll need to have a valid SSL certificate installed on your web server. This certificate must be signed by a certificate authority, have an expiration date in the future, and respond for the request domain name (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arraySSL setting info.

TODO: Complete

get_zone_settings_tls_1_2_only() 

Get Zone Enable TLS 1.3 setting.

get_zone_settings_tls_1_3(string $id) : array
API

Enable Crypto TLS 1.3 feature for this zone.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayTLS 1.3 setting info.

Get TLS Client Auth setting.

get_zone_settings_tls_client_auth(string $id) : array
API

TLS Client Auth requires Cloudflare to connect to your origin server using a client certificate (Enterprise Only).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayTLS Client Auth setting info.

TODO: Complete

get_zone_settings_true_client_ip_header() 

Get Web Application Firewall (WAF) setting.

get_zone_settings_waf(string $id) : array
API

The WAF examines HTTP requests to your website. It inspects both GET and POST requests and applies rules to help filter out illegitimate traffic from legitimate website visitors. The Cloudflare WAF inspects website addresses or URLs to detect anything out of the ordinary. If the Cloudflare WAF determines suspicious user behavior, then the WAF will ‘challenge’ the web visitor with a page that asks them to submit a CAPTCHA successfully to continue their action. If the challenge is failed, the action will be stopped. What this means is that Cloudflare’s WAF will block any traffic identified as illegitimate before it reaches your origin web server. (https://support.cloudflare.com/hc/en-us/articles/200172016).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayWeb application firewall setting info.

Get WebP setting.

get_zone_settings_webp(string $id) : array
API

When the client requesting the image supports the WebP image codec, Cloudflare will serve a WebP version of the image when WebP offers a performance advantage over the original image format.

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayWebP setting info.

Get WebSockets setting.

get_zone_settings_websockets(string $id) : array
API

WebSockets are open connections sustained between the client and the origin server. Inside a WebSockets connection, the client and the origin can pass data back and forth without having to reestablish sessions. This makes exchanging data within a WebSockets connection fast. WebSockets are often used for real-time applications such as live chat and gaming. (https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-).

api GET
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayWebsockets setting info.

List zones.

get_zones(array $args = array()) : array
API

List, search, sort, and filter your zones.

api GET
see Documentation

Parameters

$args

array

Query args to send in to API call. See API docs for details.

Returns

arrayList of available zones.

Import DNS records.

import_zone_dns_records(string $id, string $file) : array
API

You can upload your BIND config through this endpoint. It assumes that cURL is called from a location with bind_config.txt (valid BIND config) present.

api POST
see Documentation
see BIND file format

Parameters

$id

string

Zone ID.

$file

string

BIND config to upload, i.e. "@bind_config.txt".

Returns

arrayRequest details.

Initiate another zone activation check.

initiate_zone_activation_check(string $id) : array
API
api PUT
see Documentation

Parameters

$id

string

Zone ID.

Returns

arrayArray with results.

Leave organization

leave_user_org(string $id) : array
API

Remove association to an organization.

api DELETE
see Documentation

Parameters

$id

string

Organization id.

Returns

arrayArray with removed org ID.

Purge all files.

purge_zone_cache_all(string $id) : array
API

Remove ALL files from Cloudflare's cache.

api DELETE
see Documentation

Parameters

$id

string

Zone Id.

Returns

arrayPurge results.

Purge individual files by URL and Cache-Tags.

purge_zone_cache_individual(string $id, array $files = null, array $tags = null) : array
API

Granularly remove one or more files from Cloudflare's cache either by specifying the URL or the associated Cache-Tag. All tiers can purge by URL. Cache-Tag is for Enterprise only.

Cache-Tag purging has a rate limit of up to 2,000 purge API calls in every 24 hour period. You may purge up to 30 tags in one API call.

api DELETE
see Documentation

Parameters

$id

string

Zone Id.

$files

array

An array of URLs that should be removed from cache.

$tags

array

Any assets served with a Cache-Tag header that matches one of the provided values will be purged from the Cloudflare cache.

Returns

arrayPurge results.

Respond to Invitation

respond_user_invite(string $id, boolean $status) : array
API
api PATCH
see Documentation

Parameters

$id

string

Invite id.

$status

boolean

Invite status. Set to true to accept, and false to reject.

Returns

arrayArray with invites details.

HTTP response code messages.

response_code_msg(\[String] $code = '') : \[String]

Parameters

$code

\[String]

: Response code to get message from.

Returns

\[String]: Message corresponding to response code sent in.

TODO: Complete

test_zone_railguns() 

Update User

update_user(string $first_name = null, string $last_name = null, string $phone = null, string $country = null, string $zipcode = null) : array
API

Account Access: FREE, PRO, Business, Enterprise

api PATCH
see Documentation.
access public

Parameters

$first_name

string

User's first name.

$last_name

string

User's last name.

$phone

string

User's telephone number.

$country

string

User's The country in which the user lives.

$zipcode

string

The zipcode or postal code where the user lives.

Returns

arrayUpdated user info.

Update access rule.

update_user_access_rule(string $id, string $mode, string $config_target, string $config_value, string $notes = '') : array

Update rule state and/or configuration. This will be applied across all zones owned by the user.

Parameters

$id

string

Access rule ID.

$mode

string

The action to apply to a matched request. Valid values: block, challenge, whitelist.

$config_target

string

Rule configuration target. valid values: ip, ip_range, country.

$config_value

string

Rule configuration value. See API docs for details.

$notes

string

A personal note about the rule. Typically used as a reminder or explanation for the rule.

Returns

arrayUpdated access rule info.

Update a User Subscription.

update_user_subscriptions(string $subscription_id, integer $price, string $currency, string $frequency, array $optional_args = array()) : array
API
api PUT
see Documentation

Parameters

$subscription_id

string

Subscription identifier tag.

$price

integer

The price of the subscription that will be billed, in US dollars.

$currency

string

The monetary unit in which pricing information is displayed.

$frequency

string

How often the subscription is renewed automatically.

$optional_args

array

Array with optional parameters. See API docs for details.

Returns

arrayUpdated user subscription info.

Edit Zone Properties.

update_zone(string $id, boolean $paused = null, array $vanity_name_servers = null, array $plan = null) : array
API

Only one zone property can be changed at a time.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$paused

boolean

Indicates if the zone is only using Cloudflare DNS services. A true value means the zone will not receive security or performance benefits. Valid values: true|false.

$vanity_name_servers

array

An array of domains used for custom name servers. This is only available for Business and Enterprise plans.

$plan

array

The desired plan for the zone. Changing this value will create/cancel associated subscriptions. To view available plans for this zone, see Zone Plans.

Returns

arrayUpdated zone info.

Update Custom page URL.

update_zone_custom_page_details(string $id, string $page_id, string $url, string $state) : array
API
api PUT
see Documentation

Parameters

$id

string

Zone ID.

$page_id

string

Custom page ID.

$url

string

A URL that is associated with the Custom Page.

$state

string

The Custom Page state. Valid values: default, customized.

Returns

arrayCustom page info.

Update DNS record.

update_zone_dns_record(string $id, string $dns_id, string $type, string $name, string $content, integer $ttl = null, boolean $proxied = null) : array
API
api PUT
see Documentation

Parameters

$id

string

Zone ID.

$dns_id

string

DNS record ID.

$type

string

DNS record type, i.e "A".

$name

string

DNS record name, i.e "example.com".

$content

string

DNS record content, i.e "127.0.0.1".

$ttl

integer

Time to live for DNS record. Value of 1 is 'automatic'.

$proxied

boolean

Whether the record is receiving the performance and security benefits of Cloudflare.

Returns

arrayThe updated DNS record

Update a page rule.

update_zone_pagerule(string $id, string $pr_id, array $targets, array $actions, integer $priority = null, string $status = null) : array
API
api PUT
see Documentation

Parameters

$id

string

Zone ID.

$pr_id

string

Page rule ID.

$targets

array

Targets to evaluate on a request. See API docs for details.

$actions

array

The set of actions to perform if the targets of this rule match the request. Actions can redirect the url to another url or override settings (but not both).

$priority

integer

A number that indicates the preference for a page rule over another. In the case where you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a higher priority on the latter (#2) so it will override the first. Default: 1.

$status

string

Status of the page rule. Default: disabled. Valid Values: active, disabled.

Returns

arrayPage rule info.

Edit zone settings info.

update_zone_settings(string $id, array $items) : array
API

Edit settings for a zone.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$items

array

One or more zone setting objects. Must contain an ID and a value.

Returns

arrayUpdated zone setting info.

Change Always Online setting.

update_zone_settings_always_online(string $id, boolean $on) : array
API

When enabled, Always Online will serve pages from our cache if your server is offline (https://support.cloudflare.com/hc/en-us/articles/200168006).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Always Use HTTPS setting.

update_zone_settings_always_use_https(string $id, boolean $on) : array
API

Reply to all requests for URLs that use "http" with a 301 redirect to the equivalent "https" URL. If you only want to redirect for a subset of requests, consider creating an "Always use HTTPS" page rule.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Automatic HTTPS Rewrites setting.

update_zone_settings_automatic_https_rewrites(string $id, boolean $on) : array
API

Enable the Automatic HTTPS Rewrites feature for this zone.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Browser Cache TTL setting.

update_zone_settings_browser_cache_ttl(string $id, integer $seconds) : array
API

Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources will remain on your visitors' computers. Cloudflare will honor any larger times specified by your server. (https://support.cloudflare.com/hc/en-us/articles/200168276).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$seconds

integer

Default value: 14400. Valid values: 30, 60, 300, 1200, 1800, 3600, 7200, 10800, 14400, 18000, 28800, 43200, 57600, 72000, 86400, 172800, 259200, 345600, 432000, 691200, 1382400, 2073600, 2678400, 5356800, 16070400, 31536000. Notes: The minimum TTL available depends on the plan level of the zone. (Enterprise = 30, Business = 1800, Pro = 1800, Free = 1800).

Returns

arrayUpdated zone setting info.

Change Browser Check setting.

update_zone_settings_browser_check(string $id, boolean $on) : array
API

Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page. It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors). (https://support.cloudflare.com/hc/en-us/articles/200170086).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Cache Level setting.

update_zone_settings_cache_level(string $id, string $level) : array
API

Cache Level functions based off the setting level. The basic setting will cache most static resources (i.e., css, images, and JavaScript). The simplified setting will ignore the query string when delivering a cached resource. The aggressive setting will cache all static resources, including ones with a query string. (https://support.cloudflare.com/hc/en-us/articles/200168256).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$level

string

Default value: aggressive. Valid values: aggressive, basic, simplified.

Returns

arrayUpdated zone setting info.

Change Challenge TTL setting.

update_zone_settings_challenge_ttl(string $id, integer $seconds) : array
API

Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the TTL has expired the visitor will have to complete a new challenge. We recommend a 15 - 45 minute setting and will attempt to honor any setting above 45 minutes. (https://support.cloudflare.com/hc/en-us/articles/200170136).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$seconds

integer

Default value: 1800. Valid values: 300, 900, 1800, 2700, 3600, 7200, 10800, 14400, 28800, 57600, 86400, 604800, 2592000, 31536000.

Returns

arrayUpdated zone setting info.

Change Development Mode setting.

update_zone_settings_development_mode(string $id, boolean $on) : array
API

Development Mode temporarily allows you to enter development mode for your websites if you need to make changes to your site. This will bypass Cloudflare's accelerated cache and slow down your site, but is useful if you are making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right away. Once entered, development mode will last for 3 hours and then automatically toggle off.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Email Obfuscation setting.

update_zone_settings_email_obfuscation(string $id, boolean $on) : array
API

Encrypt email adresses on your web page from bots, while keeping them visible to humans. (https://support.cloudflare.com/hc/en-us/articles/200170016).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change HTTP2 setting.

update_zone_settings_http2(string $id, boolean $on) : array
API

Value of the HTTP2 setting.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change IP Geolocation setting.

update_zone_settings_ip_geolocation(string $id, boolean $on) : array
API

Enable IP Geolocation to have Cloudflare geolocate visitors to your website and pass the country code to you. (https://support.cloudflare.com/hc/en-us/articles/200168236).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change IPv6 setting.

update_zone_settings_ipv6(string $id, boolean $on) : array
API

Enable IPv6 on all subdomains that are Cloudflare enabled. (https://support.cloudflare.com/hc/en-us/articles/200168586).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Minify setting.

update_zone_settings_minify(string $id, boolean $css, boolean $html, boolean $js) : array
API

Automatically minify certain assets for your website (https://support.cloudflare.com/hc/en-us/articles/200168196).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$css

boolean

True to turn on, false to turn off.

$html

boolean

True to turn on, false to turn off.

$js

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Mirage setting.

update_zone_settings_mirage(string $id, boolean $on) : array
API

Automatically optimize image loading for website visitors on mobile devices (http://blog.cloudflare.com/mirage2-solving-mobile-speed).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Mobile Redirect setting.

update_zone_settings_mobile_redirect(string $id, boolean $status, string $mobile_subdomain, boolean $strip_uri) : array
API

Automatically redirect visitors on mobile devices to a mobile-optimized subdomain (https://support.cloudflare.com/hc/en-us/articles/200168336).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$status

boolean

True to turn on, false to turn off.

$mobile_subdomain

string

True to turn on, false to turn off.

$strip_uri

boolean

True tor false.

Returns

arrayUpdated zone setting info.

Change Opportunistic Encryption setting.

update_zone_settings_opportunistic_encryption(string $id, boolean $on) : array
API

Enable the Opportunistic Encryption feature for this zone.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

TODO: Complete.

update_zone_settings_origin_error_page_pass_thru() 

Change Polish setting.

update_zone_settings_polish(string $id, boolean $on) : array
API

Strips metadata and compresses your images for faster page load times. Basic (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster image loading. Larger JPEGs are converted to progressive images, loading a lower-resolution image first and ending in a higher-resolution version. Not recommended for hi-res photography sites.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

TODO: Complete.

update_zone_settings_prefetch_preload() 

Change pseudo_ipv4 setting.

update_zone_settings_pseudo_ipv4(string $id, boolean $on) : array
API

Value of the pseudo_ipv4 setting.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

TODO: Complete.

update_zone_settings_response_buffering() 

Change Rocket Loader setting.

update_zone_settings_rocket_loader(string $id, boolean $on) : array
API

Rocket Loader is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload. Turning on Rocket Loader will immediately improve a web page's window.onload time (assuming there is JavaScript on the page), which can have a positive impact on your Google search ranking. Automatic Mode: Rocket Loader will automatically run on the JavaScript resources on your site, with no configuration required after turning on automatic mode. Manual Mode: In order to have Rocket Loader execute for a particular script, you must add the following attribute to the script tag: "data-cfasync='true'". As your page passes through Cloudflare, we'll enable Rocket Loader for that particular script. All other JavaScript will continue to execute without Cloudflare touching the script. (https://support.cloudflare.com/hc/en-us/articles/200168056).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Security Header (HSTS) setting.

update_zone_settings_security_header(string $id, boolean $enabled, integer $max_age, boolean $include_subdomains, boolean $no_sniff) : array
API

Cloudflare security header for a zone.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$enabled

boolean

True to enable HSTS.

$max_age

integer

Max age in seconds.

$include_subdomains

boolean

True to include subdomains.

$no_sniff

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change Security Level setting.

update_zone_settings_security_level(string $id, boolean $level) : array
API

Choose the appropriate security profile for your website, which will automatically adjust each of the security settings. If you choose to customize an individual security setting, the profile will become Custom. (https://support.cloudflare.com/hc/en-us/articles/200170056).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$level

boolean

Default value: medium. Valid values: essentially_off, low, medium, high, under_attack.

Returns

arrayUpdated zone setting info.

Change Server Side Exclude setting.

update_zone_settings_server_side_exclude(string $id, boolean $on) : array
API

If there is sensitive content on your website that you want visible to real visitors, but that you want to hide from suspicious visitors, all you have to do is wrap the content with Cloudflare SSE tags. Wrap any content that you want to be excluded from suspicious visitors in the following SSE tags: . For example: Bad visitors won't see my phone number, 555-555-5555 . Note: SSE only will work with HTML. If you have HTML minification enabled, you won't see the SSE tags in your HTML source when it's served through Cloudflare. SSE will still function in this case, as Cloudflare's HTML minification and SSE functionality occur on-the-fly as the resource moves through our network to the visitor's computer. (https://support.cloudflare.com/hc/en-us/articles/200170036).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

TODO: Complete.

update_zone_settings_sort_query_string_for_cache() 

Change SSL setting.

update_zone_settings_ssl(string $id, boolean $on) : array
API

SSL encrypts your visitor's connection and safeguards credit card numbers and other personal data to and from your website. SSL can take up to 5 minutes to fully activate. Requires Cloudflare active on your root domain or www domain. Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare and your web server (all HTTP traffic). Flexible: SSL between the visitor and Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and your web server. You don't need to have an SSL cert on your web server, but your vistors will still see the site as being HTTPS enabled. Full: SSL between the visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and your web server. You'll need to have your own SSL cert or self-signed cert at the very least. Full (Strict): SSL between the visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and your web server. You'll need to have a valid SSL certificate installed on your web server. This certificate must be signed by a certificate authority, have an expiration date in the future, and respond for the request domain name (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416)

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

TODO: Complete.

update_zone_settings_tls_1_2_only() 

Change TLS 1.3 setting.

update_zone_settings_tls_1_3(string $id, boolean $on) : array
API

Enable Crypto TLS 1.3 feature for this zone.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

TODO: Complete.

update_zone_settings_tls_client_auth() 

TODO: Complete.

update_zone_settings_true_client_ip_header() 

Change Web Application Firewall (WAF) setting.

update_zone_settings_waf(string $id, boolean $on) : array
API

The WAF examines HTTP requests to your website. It inspects both GET and POST requests and applies rules to help filter out illegitimate traffic from legitimate website visitors. The Cloudflare WAF inspects website addresses or URLs to detect anything out of the ordinary. If the Cloudflare WAF determines suspicious user behavior, then the WAF will ‘challenge’ the web visitor with a page that asks them to submit a CAPTCHA successfully to continue their action. If the challenge is failed, the action will be stopped. What this means is that Cloudflare’s WAF will block any traffic identified as illegitimate before it reaches your origin web server. (https://support.cloudflare.com/hc/en-us/articles/200172016).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change WebP setting.

update_zone_settings_webp(string $id, boolean $on) : array
API

When the client requesting the image supports the WebP image codec, Cloudflare will serve a WebP version of the image when WebP offers a performance advantage over the original image format.

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Change WebSockets setting.

update_zone_settings_websockets(string $id, boolean $on) : array
API

WebSockets are open connections sustained between the client and the origin server. Inside a WebSockets connection, the client and the origin can pass data back and forth without having to reestablish sessions. This makes exchanging data within a WebSockets connection fast. WebSockets are often used for real-time applications such as live chat and gaming. (https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-).

api PATCH
see Documentation

Parameters

$id

string

Zone ID.

$on

boolean

True to turn on, false to turn off.

Returns

arrayUpdated zone setting info.

Prepares API request.

build_request(string $route, array $args = array(), array $method = 'GET') : \CloudFlareAPI
fluent This method is part of a fluent interface and will return the same instance

Parameters

$route

string

API route to make the call to.

$args

array

Arguments to pass into the API call.

$method

array

HTTP Method to use for request.

Returns

\CloudFlareAPIReturns an instance of itself so it can be chained to the fetch method.

Clear query data.

clear() 

Fetch the request from the API.

fetch() : array | \WP_Error
access private

Returns

array\WP_ErrorRequest results or WP_Error on request failure.

Check if HTTP status code is a success.

is_status_ok(integer $code) : boolean

Parameters

$code

integer

HTTP status code.

Returns

booleanTrue if status is within valid range.

Set request headers.

set_headers() 

 Properties

 

CloudFlare BaseAPI Endpoint

$base_uri : string

Default

'https://api.cloudflare.com/client/v4/'
access protected
 

Route being called.

$route : string

Default

''
 

API Key.

$api_key : string

Default

Static
 

Auth Email

$auth_email : string

Default

Static
 

User Service Key

$user_service_key : string

Default

Static