Skip to content

Hooks & Filters

ProductBay provides an extensive set of WordPress action hooks and filters, enabling developers to extend, customize, and integrate with the plugin without modifying its core source files.

Since v1.0.1

All hooks listed on this page were introduced in ProductBay 1.0.1.

Hook Naming Convention

All hooks are prefixed with productbay_ to avoid collisions:

  • Actions — Use do_action( 'productbay_*' )
  • Filters — Use apply_filters( 'productbay_*' )

Core

Hooks fired during the plugin lifecycle.

productbay_loaded

Fires after all free plugin components are initialized. This is the primary hook for add-on plugins to bootstrap themselves.

TypeAction
Parameters$plugin (Plugin) — The main plugin instance
Fileapp/Core/Plugin.php
php
add_action( 'productbay_loaded', function( $plugin ) {
    // Your add-on logic here
} );

productbay_admin_init

Fires after the admin component is set up (inside is_admin() context only).

TypeAction
Parameters$admin (Admin) — The admin instance
Fileapp/Core/Plugin.php

Data Layer

Hooks around table CRUD operations in TableRepository.

productbay_before_save_table

Filters table data before it is persisted.

TypeFilter
Parameters$data (array), $id (int)
Returnsarray — Modified table data
Fileapp/Data/TableRepository.php
php
add_filter( 'productbay_before_save_table', function( $data, $id ) {
    // Validate or modify data before save
    return $data;
}, 10, 2 );

productbay_after_save_table

Fires after a table is successfully saved.

TypeAction
Parameters$post_id (int), $data (array)
Fileapp/Data/TableRepository.php

productbay_after_delete_table

Fires after a table is deleted.

TypeAction
Parameters$id (int) — The deleted post ID
Fileapp/Data/TableRepository.php

productbay_table_data

Filters the formatted table data returned by the repository.

TypeFilter
Parameters$table_data (array), $post (WP_Post)
Returnsarray — Modified table data
Fileapp/Data/TableRepository.php
php
add_filter( 'productbay_table_data', function( $data, $post ) {
    $data['my_pro_field'] = get_post_meta( $post->ID, '_my_pro_meta', true );
    return $data;
}, 10, 2 );

API Layer

Hooks for extending the REST API and settings.

productbay_register_routes

Fires after all core REST routes are registered. Use this to register additional endpoints.

TypeAction
Parameters$router (Router) — The router instance
Fileapp/Http/Router.php
php
add_action( 'productbay_register_routes', function( $router ) {
    register_rest_route( 'productbay/v1', '/my-endpoint', [ /* ... */ ] );
} );

productbay_default_settings

Filters the default plugin settings array.

TypeFilter
Parameters$defaults (array)
Returnsarray — Modified defaults
Fileapp/Api/SettingsController.php

productbay_get_settings

Filters settings before they are returned to the frontend.

TypeFilter
Parameters$settings (array)
Returnsarray — Modified settings
Fileapp/Api/SettingsController.php

productbay_settings_updated

Fires after settings are saved.

TypeAction
Parameters$settings (array) — The saved settings
Fileapp/Api/SettingsController.php

productbay_system_status

Filters the system status data (used by the Dashboard).

TypeFilter
Parameters$status (array)
Returnsarray — Modified status data
Fileapp/Api/SystemController.php
php
add_filter( 'productbay_system_status', function( $status ) {
    $status['pro_license'] = 'active';
    return $status;
} );

Frontend Rendering

The most critical layer for extending table output. All hooks are in TableRenderer.php unless noted otherwise.

productbay_query_args

Filters WP_Query arguments before the product query executes.

TypeFilter
Parameters$args (array), $source (array), $settings (array)
Returnsarray — Modified query args
Fileapp/Frontend/TableRenderer.php
php
add_filter( 'productbay_query_args', function( $args, $source, $settings ) {
    // Example: only show featured products
    $args['tax_query'][] = [
        'taxonomy' => 'product_visibility',
        'field'    => 'name',
        'terms'    => 'featured',
    ];
    return $args;
}, 10, 3 );

productbay_table_columns

Filters the columns array before rendering.

TypeFilter
Parameters$columns (array), $table_id (int)
Returnsarray — Modified columns

productbay_cell_output

Filters a single cell's HTML output.

TypeFilter
Parameters$cell_html (string), $col (array), $product (WC_Product)
Returnsstring — Modified HTML
php
add_filter( 'productbay_cell_output', function( $html, $col, $product ) {
    if ( $col['type'] === 'my_custom_type' ) {
        return '<span>' . esc_html( $product->get_attribute('brand') ) . '</span>';
    }
    return $html;
}, 10, 3 );

productbay_table_output

Filters the complete table HTML before it is returned.

TypeFilter
Parameters$html (string), $table (array)
Returnsstring — Modified HTML

productbay_table_styles

Filters the generated scoped CSS for a table.

TypeFilter
Parameters$css (string), $table (array)
Returnsstring — Modified CSS

productbay_before_table / productbay_after_table

Actions fired before and after the table wrapper <div>.

TypeAction
Parameters$table (array)

productbay_before_row / productbay_after_row

Actions fired before and after each product row <tr>.

TypeAction
Parameters$product (WC_Product), $table (array)

productbay_toolbar_start / productbay_toolbar_end

Actions to inject content at the start or end of the toolbar area (above the table, where search and bulk actions live).

TypeAction
Parameters$table (array)

Frontend AJAX

Hooks for AJAX operations in AjaxRenderer.php.

productbay_ajax_filter_response

Filters the AJAX response for table filtering/search/pagination.

TypeFilter
Parameters$response (array), $table (array)
Returnsarray — Modified response

productbay_after_bulk_add_to_cart

Fires after a bulk add-to-cart operation completes.

TypeAction
Parameters$added_count (int), $errors (array)

Shortcode

Hooks in Shortcode.php.

productbay_shortcode_atts

Filters the parsed shortcode attributes.

TypeFilter
Parameters$atts (array)
Returnsarray — Modified attributes

productbay_enqueue_frontend_assets

Action to enqueue additional frontend assets when a ProductBay shortcode is rendered.

TypeAction
Parameters(none)

Admin

Hooks in Admin.php.

productbay_after_register_menu

Fires after all admin menu items are registered.

TypeAction
Parameters(none)

productbay_admin_script_data

Filters the data passed to the React admin app via wp_localize_script.

TypeFilter
Parameters$data (array)
Returnsarray — Modified script data
php
add_filter( 'productbay_admin_script_data', function( $data ) {
    $data['proActive'] = true;
    $data['license']   = 'valid';
    return $data;
} );

productbay_enqueue_admin_assets

Action to enqueue additional admin assets on ProductBay pages.

TypeAction
Parameters(none)

Released under the GPL-2.0+ License.