Filter: clarkson_core_create_object_callback

apply_filters( 'clarkson_core_create_object_callback', false, $type, $post_id ) → {string}

Allows to control object creation before Clarkson Core determines the correct class to use. For example by calling "wc_get_product".
Parameters:
Name Type Description
false callable | bool Callable that determines how the class should be instantiated. False means no custom object creation will be used.
$type string Sanitized class name of what Clarkson Core would load as an object.
$post_id int | string Post ID that an object is being created for.
Since:
  • 0.3.1
Source:
See:
Returns:
Class name of object to be created.
Type
string
Example
// Use a different object factory then the default one provided by Clarkson Core.
add_filter( 'clarkson_core_create_object_callback', function( $callback, $type, $post_id ) {
 if ( $type === '\Clarkson_Core\Object\shop_order' ){
     $callback = 'wc_get_order'; // wc_get_order is a callable function when Woocommerce is enabled.
 }
 return $type;
} );