I’m creating an extension for the dashboard that will need to execute a specific function on the child sites, so I’m wondering what are the best practices of doing it without using the Snippets extension, for example.
I was thinking of creating a child extension to be installed on the child sites that would receive the request and execute the function. I found the $callableFunctions array on the class-mainwp-child-callable.php file, but it has no filters to add new entries, so I’m not really sure how to add my own callable function, or what step I should take.
Thanks for reaching out. I am happy to see MainWP users using one of the biggest advantages of the MainWP system which is flexibility for custom features.
Have you checked the mainwp_child_extra_execution filter in the class-mainwp-child-callable.php` file?
/**
* Method extra_execution()
*
* Additional functions to execute.
*
* @uses \MainWP\Child\MainWP_Helper::write()
*/
public function extra_execution() {
$post = $_POST;
$information = array();
/**
* Filter 'mainwp_child_extra_execution'
*
* Additional functions to execute through the filter.
*
* @param array $information An array containing the synchronization information.
* @param mixed $post Contains the POST request.
*
* @since 4.0
*/
$information = apply_filters( 'mainwp_child_extra_execution', $information, $post );
MainWP_Helper::write( $information );
}
I believe that this will help you accomplish what you need.