Contents

Hooks reference - Plugixa Chauffeur

The plugin fires 7 actions and 14 filters, all prefixed plugixa_chauffeur_. One filter exists only in Pro and is marked PRO.

The Pro features are themselves built on these hooks: the pricing rule engine and the flat-rate service are ordinary listeners on the filters below. Anything they do, your code can do too.

The ones you are most likely to want

Hook Type What it is for
plugixa_chauffeur_booking_created action React to a new booking from the wizard
plugixa_chauffeur_booking_status_changed action React to a booking moving from one status to another
plugixa_chauffeur_booking_paid action React to a confirmed Stripe payment
plugixa_chauffeur_fare filter Change the price of a quote or a booking
plugixa_chauffeur_manage_capability filter Let a role other than Administrator manage bookings

Actions

Lifecycle

plugixa_chauffeur_loaded

Fires once the plugin has finished starting, on plugins_loaded, after every module has registered its hooks.

Parameter Type Meaning
$container PlugixaChauffeur\Core\Container The plugin’s service container
add_action( 'plugixa_chauffeur_loaded', function ( $container ) {
	// The booking plugin is present and booted.
} );

plugixa_chauffeur_activated

Fires when the plugin is activated, after its tables, capabilities and default options are in place. No parameters.

add_action( 'plugixa_chauffeur_activated', function () {
	// Runs once per activation.
} );

plugixa_chauffeur_fs_loaded

Fires when the Freemius SDK, which handles licensing and updates, has been loaded. It fires while the plugin’s main file is being read, before plugins_loaded, so a listener has to be attached earlier than that, for example from a must-use plugin. It does not fire on a copy of the plugin that has no SDK or whose Freemius ID has been blanked. No parameters.

add_action( 'plugixa_chauffeur_fs_loaded', function () {
	// The licensing SDK is available.
} );

REST

plugixa_chauffeur_register_rest_routes

Fires on rest_api_init, after the plugin has registered its own routes. Use it to add routes alongside them. See the REST API.

Parameter Type Meaning
$namespace string plugixa-chauffeur/v1
$container PlugixaChauffeur\Core\Container The plugin’s service container
add_action( 'plugixa_chauffeur_register_rest_routes', function ( $namespace ) {
	register_rest_route( $namespace, '/my-addon/ping', array(
		'methods'             => 'GET',
		'callback'            => fn() => array( 'ok' => true ),
		'permission_callback' => fn() => current_user_can( 'plugixa_chauffeur_manage' ),
	) );
} );

Bookings

plugixa_chauffeur_booking_created

Fires after a booking made through the public wizard has been saved. The plugin’s own booking emails are sent from this action.

It does not fire for a booking created in the admin through POST /bookings.

Parameter Type Meaning
$booking_id int The new booking’s ID
$data array The row that was inserted: booking number, service type, addresses, pickup time, customer details, prices, currency, payment method and so on

For a Stripe booking this fires before the customer has paid. Use plugixa_chauffeur_booking_paid for the payment.

add_action( 'plugixa_chauffeur_booking_created', function ( $booking_id, $data ) {
	error_log( sprintf( 'New booking %s for %s', $data['booking_number'], $data['customer_email'] ) );
}, 10, 2 );

plugixa_chauffeur_booking_status_changed

Fires when a booking’s status actually changes. It has two sources: a booking updated in the admin or through PUT /bookings/{id}, and a Stripe payment that moves a booking from pending to processing. The status-change email to the customer is sent from this action.

Parameter Type Meaning
$booking_id int The booking’s ID
$old_status string The status before the change
$new_status string The status after the change

The statuses are pending, processing, completed, cancelled, on_hold, refunded and failed.

add_action( 'plugixa_chauffeur_booking_status_changed', function ( $booking_id, $old, $new ) {
	if ( 'completed' === $new ) {
		// Ask for a review, update a CRM, and so on.
	}
}, 10, 3 );

plugixa_chauffeur_booking_paid

Fires when a verified Stripe webhook marks a booking as paid, after the row has been updated. It fires once per booking: a repeated webhook for a booking that is already paid does nothing. It does not fire when you set the payment status to paid by hand in the admin.

Parameter Type Meaning
$booking_id int The booking’s ID

When the booking was pending, plugixa_chauffeur_booking_status_changed fires straight after this action.

add_action( 'plugixa_chauffeur_booking_paid', function ( $booking_id ) {
	// Payment confirmed by Stripe.
} );

Filters

Permissions

plugixa_chauffeur_manage_capability

The capability needed to see the admin menu and to use every managed REST route. The default is plugixa_chauffeur_manage, which activation gives to administrators.

Parameter Type Meaning
$capability string plugixa_chauffeur_manage
add_filter( 'plugixa_chauffeur_manage_capability', function () {
	return 'edit_others_posts'; // Editors and above.
} );

Bookings contain customer names, emails, phone numbers and addresses. Choose a capability that only trusted staff hold.

The settings routes are not covered by this filter. They need manage_options.

plugixa_chauffeur_delete_capability

The capability needed, in addition to the manage capability, to call any DELETE route. The default is plugixa_chauffeur_delete.

Parameter Type Meaning
$capability string plugixa_chauffeur_delete
add_filter( 'plugixa_chauffeur_delete_capability', function () {
	return 'manage_options'; // Only administrators delete records.
} );

plugixa_chauffeur_invoice_capability PRO

The capability needed to open a booking’s invoice page. The default is plugixa_chauffeur_manage. This filter is separate from plugixa_chauffeur_manage_capability: changing one does not change the other.

Parameter Type Meaning
$capability string plugixa_chauffeur_manage
add_filter( 'plugixa_chauffeur_invoice_capability', function () {
	return 'edit_others_posts';
} );

Pricing and booking

plugixa_chauffeur_fare

Filters the fare for one vehicle. It runs once per vehicle when the wizard asks for a quote, and once more for the chosen vehicle when the booking is created, so whatever you return is both what the customer sees and what is charged.

Parameter Type Meaning
$fare array price_base, price_distance, price_time and price_total
$context array See below

$context holds service_type, transfer_type (one_way or return), distance_km, duration_hours, passengers, pickup_datetime (as the customer entered it), route_id, vehicle (the vehicle row) and currency.

Only price_total is charged. In Pro the flat-rate service listens at priority 5 and the pricing rule engine at priority 10, so the default priority runs alongside the rules and a later priority runs after them.

add_filter( 'plugixa_chauffeur_fare', function ( $fare, $context ) {
	if ( $context['passengers'] >= 6 ) {
		$fare['price_total'] = round( $fare['price_total'] + 15, 2 ); // Large-group fee.
	}
	return $fare;
}, 20, 2 );

plugixa_chauffeur_booking_data

Filters the booking row just before the wizard’s booking is inserted. Use it to derive or adjust columns. Keys must be real columns of the bookings table, or the insert fails.

Parameter Type Meaning
$data array The row about to be inserted
$params array The request body as sent, not sanitised
$form array The published booking form’s public columns
add_filter( 'plugixa_chauffeur_booking_data', function ( $data, $params, $form ) {
	if ( ! empty( $params['flight_number'] ) ) {
		$data['notes'] = trim( $data['notes'] . "\nFlight: " . sanitize_text_field( $params['flight_number'] ) );
	}
	return $data;
}, 10, 3 );

plugixa_chauffeur_form_config

Filters the configuration the wizard receives from GET /public/form/{id}. Add service types or extra keys for your own front-end code here. The response is public, so do not put anything private in it.

Parameter Type Meaning
$config array id, name, currency, service_types, default_service_type, enable_return, min_passengers, min_lead_time, distance_unit, payment_methods, availability
$form array The published booking form’s public columns

After the filter, a default_service_type that is not among service_types is replaced by the first one that is.

add_filter( 'plugixa_chauffeur_form_config', function ( $config, $form ) {
	$config['support_phone'] = '+44 20 7946 0000';
	return $config;
}, 10, 2 );

plugixa_chauffeur_allowed_service_types

Filters the service types a booking form may have as its default. The core allows distance and hourly; Pro adds flat. A value not in the list is saved as distance.

Parameter Type Meaning
$types string[] array( 'distance', 'hourly' )
add_filter( 'plugixa_chauffeur_allowed_service_types', function ( $types ) {
	$types[] = 'tour';
	return $types;
} );

Settings

plugixa_chauffeur_settings_defaults

Filters the default value of every setting. A key added here is returned by the settings route and handed to the admin app even before it has ever been saved. Pro uses it to add the invoice letterhead settings.

Parameter Type Meaning
$defaults array Setting key to default value
add_filter( 'plugixa_chauffeur_settings_defaults', function ( $defaults ) {
	$defaults['my_addon_option'] = '';
	return $defaults;
} );

Activation writes the defaults into the stored settings, and a stored value always wins over a default. Changing the default of a built-in key here therefore has no effect on a site where the plugin is already active.

plugixa_chauffeur_sanitize_settings

Filters the values of a settings save after the core has sanitised them and before they are merged into the stored settings. The core treats an unknown string key as a single line of text; use this filter when a key of yours needs different handling.

Parameter Type Meaning
$sanitized array The values about to be merged
$params array The request body as sent
$current array The settings currently stored
add_filter( 'plugixa_chauffeur_sanitize_settings', function ( $sanitized, $params, $current ) {
	if ( array_key_exists( 'my_addon_option', $params ) ) {
		$sanitized['my_addon_option'] = sanitize_textarea_field( (string) $params['my_addon_option'] );
	}
	return $sanitized;
}, 10, 3 );

plugixa_chauffeur_validate_settings

The last chance to refuse a settings save. Return a WP_Error to stop the save and send its message back; return anything else to let it through.

Parameter Type Meaning
$error null Null, or a WP_Error from an earlier listener
$merged array The complete settings that would be stored
add_filter( 'plugixa_chauffeur_validate_settings', function ( $error, $merged ) {
	if ( ! empty( $merged['payment_stripe_enabled'] ) && empty( $merged['stripe_webhook_secret'] ) ) {
		return new WP_Error( 'my_addon_stripe', 'Add the webhook signing secret before enabling Stripe.', array( 'status' => 400 ) );
	}
	return $error;
}, 10, 2 );

Interface text and output

plugixa_chauffeur_wizard_i18n

Filters the labels handed to the booking wizard’s script. Pro uses it to add the flat-rate labels.

Parameter Type Meaning
$strings array Label key to text, such as pickup, dropoff, next, confirm, thankYou, plus steps, the list of the four step names
add_filter( 'plugixa_chauffeur_wizard_i18n', function ( $strings ) {
	$strings['confirm'] = 'Request this ride';
	return $strings;
} );

plugixa_chauffeur_admin_i18n_strings

Filters the translated labels handed to the admin app: the navigation entries, the sidebar group names and the common button words. Pro uses it to add the labels of its own screens.

Parameter Type Meaning
$strings array Label key to text, such as dashboard, bookings, nav_fleet, save
add_filter( 'plugixa_chauffeur_admin_i18n_strings', function ( $strings ) {
	$strings['vehicles'] = 'Fleet';
	return $strings;
} );

plugixa_chauffeur_allowed_html

Filters the list of HTML elements and attributes allowed in the markup the plugin prints on the front end, which is the booking form’s container. The list starts from what WordPress allows in post content and adds form controls, inline SVG and ARIA attributes. Scripts and style elements are never allowed.

Parameter Type Meaning
$allowed array A wp_kses() allowlist
$context string The rendering context, frontend
add_filter( 'plugixa_chauffeur_allowed_html', function ( $allowed, $context ) {
	$allowed['div']['data-my-addon'] = true;
	return $allowed;
}, 10, 2 );

Extending the plugin

plugixa_chauffeur_modules

Filters the list of module classes the plugin boots. This is how an add-on contributes a module from outside the plugin’s directory. Each entry must be the name of a loadable class that implements PlugixaChauffeur\Core\Modules\ModuleInterface; anything else is skipped. A module that throws while starting is skipped too, and reported in the error log when WP_DEBUG is on.

Parameter Type Meaning
$classes string[] Fully qualified module class names

The filter runs on plugins_loaded at the default priority, so attach your listener before then, for example when your own plugin’s main file is read.

add_filter( 'plugixa_chauffeur_modules', function ( $classes ) {
	$classes[] = \MyAddon\Chauffeur\Module::class;
	return $classes;
} );

Hooks the plugin reads but does not own

The multilingual helper reads three of WPML’s filters, wpml_current_language, wpml_default_language and wpml_active_languages. They belong to WPML. See Multilingual.

Quick Links