monsterinsights_is_valid_ua

Is valid ua code.

Description

(string|false) monsterinsights_is_valid_ua( (string) $ua_code = '' ); 

Returns (string|false)

Return cleaned ua string if valid, else returns false.

Parameters (1)

0. $ua_code — Optional. (string) => ''
UA code to check validity for.

Usage

  1. if ( !function_exists( 'monsterinsights_is_valid_ua' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/options.php'; 
  3.  
  4. // UA code to check validity for. 
  5. $ua_code = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = monsterinsights_is_valid_ua($ua_code); 
  9.  

Defined (1)

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

/includes/options.php  
  1. function monsterinsights_is_valid_ua( $ua_code = '' ) { 
  2. $ua_code = (string) $ua_code; // Rare case, but let's make sure it never happens. 
  3. $ua_code = trim( $ua_code ); 
  4.  
  5. if ( empty( $ua_code ) ) { 
  6. return ''; 
  7.  
  8. // Replace all type of dashes (n-dash, m-dash, minus) with normal dashes. 
  9. $ua_code = str_replace( array( '*', '*', '*' ), '-', $ua_code ); 
  10.  
  11. if ( preg_match( "/^(UA|YT|MO)-\d{4, }-\d+$/", strval( $ua_code ) ) ) { 
  12. return $ua_code; 
  13. } else { 
  14. return '';