WPSEO_Shortlinker

Helps with creating shortlinks in the plugin.

Defined (1)

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

/inc/class-wpseo-shortlinker.php  
  1. class WPSEO_Shortlinker { 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. protected $version; 
  7.  
  8. /** 
  9. * @param string $version The version to put in the utm_content tag. 
  10. */ 
  11. public function __construct( $version ) { 
  12. $this->version = $version; 
  13.  
  14. /** 
  15. * Builds a URL to use in the plugin as shortlink. 
  16. * @param string $url The URL to build upon. 
  17. * @return string The final URL. 
  18. */ 
  19. public function build_shortlink( $url ) { 
  20. return $url . '?utm_content=' . $this->version; 
  21.  
  22. /** 
  23. * Returns a version of the URL with a utm_content with the current version. 
  24. * @param string $url The URL to build upon. 
  25. * @return string The final URL. 
  26. */ 
  27. public static function get( $url ) { 
  28. $version = WPSEO_VERSION; 
  29.  
  30. $version = apply_filters( 'wpseo_shortlink_version', $version ); 
  31.  
  32. $shortlinker = new WPSEO_Shortlinker( $version ); 
  33.  
  34. return $shortlinker->build_shortlink( $url ); 
  35.  
  36. /** 
  37. * Echoes a version of the URL with a utm_content with the current version. 
  38. * @param string $url The URL to build upon. 
  39. */ 
  40. public static function show( $url ) { 
  41. echo esc_url( self::get( $url ) );