googleapps_validate_domain_and_dir

Check that the domain blogs to a Google Apps domain.

Description

googleapps_validate_domain_and_dir( (string) $domain, (string) $dir ); 

Parameters (2)

0. $domain (string)
The domain.
1. $dir (string)
The dir.

Usage

  1. if ( !function_exists( 'googleapps_validate_domain_and_dir' ) ) { 
  2. require_once '/modules/shortcodes/googleapps.php'; 
  3.  
  4. // The domain. 
  5. $domain = ''; 
  6.  
  7. // The dir. 
  8. $dir = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = googleapps_validate_domain_and_dir($domain, $dir); 
  12.  

Defined (1)

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

/modules/shortcodes/googleapps.php  
  1. function googleapps_validate_domain_and_dir( $domain, $dir ) { 
  2. if ( ! in_array( $domain, array( 'docs', 'drive', 'www', 'spreadsheets', 'calendar' ) ) ) { 
  3. return false; 
  4.  
  5. // Calendars 
  6. if ( ( 'www' === $domain || 'calendar' === $domain ) && 'calendar/' !== substr( $dir, 0, 9 ) ) { 
  7. return false; 
  8.  
  9. // Docs 
  10. if ( in_array( $domain, array( 'docs', 'drive' ) ) && ! preg_match( '![-\.\w/]*(presentation/embed|presentation/d/(.*)|present/embed|document/pub|spreadsheets/d/(.*)|document/d/(e/)?[\w-]+/pub|file/d/[\w-]+/preview|viewer|forms/d/(.*)/viewform|spreadsheet/\w+)$!', $dir ) ) { 
  11. return false; 
  12.  
  13. // Spreadsheets 
  14. if ( 'spreadsheets' == $domain && ! preg_match( '!^([-\.\w/]+/pub|[-\.\w/]*embeddedform)$!', $dir ) ) { 
  15. return false; 
  16.  
  17. return true;