Jetpack_Constants

Class Jetpack_Constants.

Defined (1)

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

/class.jetpack-constants.php  
  1. class Jetpack_Constants { 
  2. static $set_constants = array(); 
  3.  
  4. /** 
  5. * Checks if a "constant" has been set in Jetpack_Constants, and if not,  
  6. * checks if the constant was defined with define( 'name', 'value ). 
  7. * @param $name string The name of the constant 
  8. * @return bool 
  9. */ 
  10. public static function is_defined( $name ) { 
  11. return array_key_exists( $name, self::$set_constants ) 
  12. ? true 
  13. : defined( $name ); 
  14.  
  15. /** 
  16. * Attempts to retrieve the "constant" from Jetpack_Constants, and if it hasn't been set,  
  17. * then attempts to get the constant with the constant() function. 
  18. * @param $name 
  19. * @return mixed null if the constant does not exist or the value of the constant. 
  20. */ 
  21. public static function get_constant( $name ) { 
  22. if ( array_key_exists( $name, self::$set_constants ) ) { 
  23. return self::$set_constants[ $name ]; 
  24.  
  25. return defined( $name ) ? constant( $name ) : null; 
  26.  
  27. /** 
  28. * Sets the value of the "constant" within Jetpack_Constants. 
  29. * @param $name string The name of the "constant" 
  30. * @param $value string The value of the "constant" 
  31. */ 
  32. public static function set_constant( $name, $value ) { 
  33. self::$set_constants[ $name ] = $value; 
  34.  
  35. /** 
  36. * Will unset a "constant" from Jetpack_Constants if the constant exists. 
  37. * @param $name string The name of the "constant" 
  38. * @return bool Whether the constant was removed. 
  39. */ 
  40. public static function clear_single_constant( $name ) { 
  41. if ( ! array_key_exists( $name, self::$set_constants ) ) { 
  42. return false; 
  43.  
  44. unset( self::$set_constants[ $name ] ); 
  45. return true; 
  46.  
  47. /** 
  48. * Resets all of the constants within Jetpack_Constants. 
  49. */ 
  50. public static function clear_constants() { 
  51. self::$set_constants = array();