คลิก update plugin ส่งเมลแจ้ง

กดอัพเดท Plugin เมื่อไร ก็จะส่งเมลแจ้งเตือน hook ไปที่ upgrader_process_complete

function wp_upe_upgrade_completed( $upgrader_object, $options ) {
  if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) {
    foreach( $options['plugins'] as $plugin ) {
      $to       = 'oarvoodoo@gmail.com';
      $subject  = 'Phuket Tropical Real Estate - Plugin update';
      $body     = '<b>Plugin Name : </b> '.$plugin_data['Name'];
      $body    .= '<b>Plugin URI : </b> '.$plugin_data['PluginURI'];
      $body    .= '<b>Version : </b> '.$plugin_data['Version'];
      $body    .= '<b>Description : </b> '.$plugin_data['Description'];
      $body    .= '<b>Author : </b> '.$plugin_data['Author'];
      $body    .= '<b>Author URI : </b> '.$plugin_data['AuthorURI'];
      $body    .= '<b>Text Domain : </b> '.$plugin_data['TextDomain'];
      $body    .= '<b>Domain Path : </b> '.$plugin_data['DomainPath'];
      $body    .= '<b>Network : </b> '.$plugin_data['Network'];
      $headers  = array('Content-Type: text/html; charset=UTF-8');
      wp_mail( $to, $subject, $body, $headers );
    }
  }
}
add_action( 'upgrader_process_complete', 'wp_upe_upgrade_completed', 10, 2 );

เอาไปวางไว้ใน functions.php นะครับ

Leave a Reply

Your email address will not be published. Required fields are marked *