Hey, WordPress web developer :)

Check out WPMU DEV

Skip to Main Content
Docs / / Hummingbird API Docs

7. Hummingbird API Docs

Written by Anton Vanyukov | Last updated: October 17, 2018
Actions
Advanced Tools – Database Cleanup
/core/modules/class-module-advanced.php
Performance Test – Reporting
/core/modules/class-module-performance.php
Caching – Page Cache
/core/modules/class-module-page-cache.php
REST API
Module status endpoint
Clear cache endpoint

7.1 Action: wphb_delete_db_data

Link to chapter 1

Description

Can be used to run certain actions or configure notifications for database cleanup actions. Will fire after the database cleanup task in Advanced Tools – Database Cleanup.

Usage

add_action( ‘wphb_delete_db_data’, ‘database_cleanup’, 10, 2 );

Parameters

$type
String
Data type that was cleared from the database. Can return following values: all, revisions, drafts, trash, spam, trash_comment, expired_transients, transients.
$items
Integer
Number of items that was cleared from the database for the selected data type.

Example

add_action( ‘wphb_delete_db_data’, ‘database_cleanup’, 10, 2 );
function database_cleanup( $type, $items ) {
    echo ”Purged data type: {$type}, cleared out {$items} entries”;
}

7.2 Action: wphb_get_performance_report

Link to chapter 2

Description

Will fire after Hummingbird fetches the latest Performance report.

Usage

add_action( ‘wphb_get_performance_report’, ‘performance_report’ );

Parameters

$report
Object
Report data object. Contains id, time, url, score, score_class, title, response_code, page_stats and rule_result objects from the Page Speed report (see https://developers.google.com/speed/docs/insights/v4/reference/pagespeedapi/runpagespeed for a better description about the report format).

Example

add_action( ‘wphb_get_performance_report’, ‘performance_report’ );
function performance_report( $report ) {
    echo ”Received performance report for {$report->url} with a score of {$report->score}”;
}

7.3 Action: wphb_clear_page_cache

Link to chapter 3

Description

Allows to clear the page cache.

Usage

do_action( ‘wphb_clear_page_cache’, $page_id );

Parameters

$page_id
Integer
Optional parameter. ID of the page/post to clear the cache for. If not set, will clear all the cache.

Example

// Clear the cache for post ID = 12
do_action( ‘wphb_clear_page_cache’, 12 );

// Clear all the cache
do_action( ‘wphb_clear_page_cache’ );

7.4 Endpoint: /status/(?P<module>[\\w-]+)

Link to chapter 4

Description

Allows to fetch the status of Gzip compression and Browser caching modules.

Usage

Query
http://example.com/wp-json/hummingbird/v1/status/gzip

Return
{
    “module_active”: true,
    “data”: {
        “HTML”: true,
        “JavaScript”: true,
        “CSS”: true
    }
}

Query
http://example.com/wp-json/hummingbird/v1/status/caching

Return
{
    “module_active”: true,
    “data”: {
        “javascript”: false,
        “css”: false,
        “media”: false,
        “images”: false
    }
}

7.5 Endpoint: /clear_cache/(?P<module>[\\w-]+)

Link to chapter 5

Description

Allow to clear the cache for various Hummingbird modules.

Usage

Query
http://example.com/wp-json/hummingbird/v1/clear-cache/

List of module names:

  • page_cache
  • performance
  • gravatar
  • minify
  • cloudflare
Live Chat

Hi, I’m available right now to answer any of your questions :)

Chat Now
Email Us Find out more