PLL_Links_Abstract_Domain

Links model for use when using one domain or subdomain per language.

Defined (1)

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

/include/links-abstract-domain.php  
  1. abstract class PLL_Links_Abstract_Domain extends PLL_Links_Permalinks { 
  2.  
  3. /** 
  4. * Constructor 
  5. * @since 2.0 
  6. * @param object $model PLL_Model instance 
  7. */ 
  8. public function __construct( &$model ) { 
  9. parent::__construct( $model ); 
  10.  
  11. // Avoid cross domain requests ( mainly for custom fonts ) 
  12. add_filter( 'content_url', array( $this, 'site_url' ) ); 
  13. add_filter( 'plugins_url', array( $this, 'site_url' ) ); 
  14. add_filter( 'rest_url', array( $this, 'site_url' ) ); 
  15. add_filter( 'upload_dir', array( $this, 'upload_dir' ) ); 
  16.  
  17. /** 
  18. * Returns the current site url 
  19. * @since 1.8 
  20. * @param string $url 
  21. * @return string 
  22. */ 
  23. public function site_url( $url ) { 
  24. $lang = $this->get_language_from_url(); 
  25. $lang = $this->model->get_language( $lang ); 
  26. return $this->add_language_to_link( $url, $lang ); 
  27.  
  28. /** 
  29. * Fix the domain for upload directory 
  30. * @since 2.0.6 
  31. * @param array $uploads 
  32. * @return array 
  33. */ 
  34. public function upload_dir( $uploads ) { 
  35. $lang = $this->get_language_from_url(); 
  36. $lang = $this->model->get_language( $lang ); 
  37. $uploads['url'] = $this->add_language_to_link( $uploads['url'], $lang ); 
  38. $uploads['baseurl'] = $this->add_language_to_link( $uploads['baseurl'], $lang ); 
  39. return $uploads;