gde_sanitize_dims

Sanitize dimensions (width, height).

Description

(string) gde_sanitize_dims( $dim ); 

Returns (string)

Sanitized dimensions, or false if value is invalid

Parameters (1)

0. $dim
The dim.

Usage

  1. if ( !function_exists( 'gde_sanitize_dims' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/functions.php'; 
  3.  
  4. // The dim. 
  5. $dim = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = gde_sanitize_dims($dim); 
  9.  

Defined (1)

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

/functions.php  
  1. function gde_sanitize_dims( $dim ) { 
  2. // remove any spacing junk 
  3. $dim = trim( str_replace( " ", "", $dim ) ); 
  4.  
  5. if ( ! strstr( $dim, '%' ) ) { 
  6. $type = "px"; 
  7. $dim = preg_replace( "/[^0-9]*/", '', $dim ); 
  8. } else { 
  9. $type = "%"; 
  10. $dim = preg_replace( "/[^0-9]*/", '', $dim ); 
  11. if ( (int) $dim > 100 ) { 
  12. $dim = "100"; 
  13.  
  14. if ( $dim ) { 
  15. return $dim.$type; 
  16. } else { 
  17. return false;