Skip to content

added developer hooks for the data#8

Merged
scottf-tvw merged 1 commit intoTVWIT:mainfrom
simplistik:developer-hooks
Mar 3, 2025
Merged

added developer hooks for the data#8
scottf-tvw merged 1 commit intoTVWIT:mainfrom
simplistik:developer-hooks

Conversation

@simplistik
Copy link
Contributor

New Hooks Added to Invintus Event Processing

1. invintus/data/before_save (Filter)

Allows modification of event data before it is saved to the database.

Parameters:

  • $data (array) The event data to be saved
  • $events (array) Array of existing post IDs if this is an update, empty array if new
  • Returns: (array) Modified event data

Example usage:

add_filter( 'invintus/data/before_save', function( $data, $events ) {
  // Modify data before save
  $data['post_title'] = '[Modified] ' . $data['post_title'];
  return $data;
}, 10, 2 );

2. invintus/data/after_save (Action)

Fires after an event has been saved to the database.

Parameters:

  • $data (array) The event data that was saved
  • $post_id (int) The WordPress post ID
  • $operation (string) The type of operation ('insert' or 'update')

Example usage:

add_action( 'invintus/data/after_save', function( $data, $post_id, $operation ) {
  // Clean content and store as custom meta
  $content = preg_replace( '/<!--.*?-->/s', '', $data['post_content'] );
  update_post_meta( $post_id, 'clean_description', trim( $content ) );
}, 10, 3 );

Note: The before_save filter runs before both insert and update operations, while the after_save action runs after successful completion of either operation.

Developer Note: The examples above use anonymous functions for brevity and clarity. In production code, it's recommended to use named functions following WordPress coding standards. For example:

function my_invintus_after_save_handler( $data, $post_id, $operation ) {
  // Handler code here
}

add_action( 'invintus/data/after_save', 'my_invintus_after_save_handler', 10, 3 );

invintus/data/before_save
invintus/data/after_save
invintus/data/after_save
@scottf-tvw scottf-tvw merged commit 13b640a into TVWIT:main Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants