Skip to content

Consider adding automatically prefixed pre and post action hooks on CRUD methods within query class #138

@arraypress

Description

@arraypress

Here is an example of a function within my code base for a third-party plugin I am building for EDD 3.0:

function delete_automation( $automation_id = 0 ) {
	$automation_query = new Automation_Query();

	// Pre-increase order coupon rule use count
	do_action( 'eddot_pre_delete_automation', $automation_id );

	$retval = $automation_query->delete_item( $automation_id );

	// Pre-increase order coupon rule use count
	do_action( 'eddot_post_delete_automation', $retval, $automation_id );

	return $retval;
}

For almost all methods I had to add pre and post do_actions passing in the ID and return value, which bloats the code base a bit too much for my liking.

Much like the transition method hook, it would be useful to have these actions automatically generated for all the main CRUD methods. Ideally it should be possible to override that prefix too if you are building an add-on for another plugin (like EDD 3.0). Maybe this override could be defined in the query class schema or somewhere similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions