New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows the theme to override object creation #131

jmslbam opened this Issue Jul 12, 2018 · 1 comment


None yet
1 participant
Copy link

jmslbam commented Jul 12, 2018

See PR #103

The filter clarkson_create_object_callback allows the theme to control object creation before Clarkson Core determines the correct class to use.
This can be used when a factory maps a single post-type to multiple classes. An example of this use case is the WooCommerce product post-type. Behind the scenes the wc_get_product($id) function maps the product id to a more specific class, such as WC_Product_Simple or WC_Product_Grouped, based on metadata. A more basic use case is if you want to let a plugin handle object creation instead of Clarkson-Core for a specific post-type.

Example implementation:

    'clarkson_create_object_callback', function( $callback, $type ) {
        if ( 'product' === $type ) {
            return 'wc_get_product';
        return false;
    }, 10, 3

@jmslbam jmslbam added this to the 0.3.0 milestone Jul 12, 2018

@jmslbam jmslbam self-assigned this Jul 12, 2018


This comment has been minimized.

Copy link
Contributor Author

jmslbam commented Jul 12, 2018

closed via #103

@jmslbam jmslbam closed this Jul 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment