delete_transient

Delete a transient.

Description

delete_transient( (string) $transient ); 

Parameters (1)

0. $transient (string)
Transient name. Expected to not be SQL-escaped.

Usage

  1. if ( !function_exists( 'delete_transient' ) ) { 
  2. require_once ABSPATH . WPINC . '/option.php'; 
  3.  
  4. // Transient name. Expected to not be SQL-escaped. 
  5. $transient = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = delete_transient($transient); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/option.php  
  1. function delete_transient( $transient ) { 
  2.  
  3. /** 
  4. * Fires immediately before a specific transient is deleted. 
  5. * The dynamic portion of the hook name, `$transient`, refers to the transient name. 
  6. * @since 3.0.0 
  7. * @param string $transient Transient name. 
  8. */ 
  9. do_action( "delete_transient_{$transient}", $transient ); 
  10.  
  11. $result = wp_cache_delete( $transient, 'transient' ); 
  12. } else { 
  13. $option_timeout = '_transient_timeout_' . $transient; 
  14. $option = '_transient_' . $transient; 
  15. $result = delete_option( $option ); 
  16. if ( $result ) 
  17. delete_option( $option_timeout ); 
  18.  
  19. if ( $result ) { 
  20.  
  21. /** 
  22. * Fires after a transient is deleted. 
  23. * @since 3.0.0 
  24. * @param string $transient Deleted transient name. 
  25. */ 
  26. do_action( 'deleted_transient', $transient ); 
  27.  
  28. return $result;