Strattic Developers by Elementor
,

Strattic Publish Event Hooks

Strattic fires a WordPress action hook when publish completes. The hook passes one parameter to the callback functions, a publish object with the following properties:

  • publish_id – the ID of the publish used internally in the Strattic system. This ID is unique and a positive integer.
  • publish_type – the type of publish (quick/full/selective/forced)
  • distribution_type – the type of distribution the publish was for (live/preview)
  • start_time – the start time of the publish
  • status – the status of the publish
add_action( 'strattic_publish_completed', 'send_publish_completed_email', 10, 1 );
function send_publish_completed_email( $publish ) {
    $dist_type  = $publish['distribution_type'];
    $type       = $publish['publish_type'];

    $start_time = new DateTime();
    $start_time->setTimestamp( strtotime( $publish['start_time'] ) );

    $current_time = new DateTime();
    $current_time->setTimestamp( time() );

    $duration = $start_time->diff( $current_time, true );

    $body    = ucwords( $type ) . ' publish to ' . $dist_type . ' completed. Duration: ' . $duration->format('%H:%I:%S');

    mail( 'admin@yoursite.com', 'Publish Completed', $body );
}