class-link-utils.php 540 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Links
  6. */
  7. /**
  8. * Represents the utils for the links module.
  9. */
  10. class WPSEO_Link_Utils {
  11. /**
  12. * Returns the value that is part of the given url.
  13. *
  14. * @param string $url The url to parse.
  15. * @param string $part The url part to use.
  16. *
  17. * @return string The value of the url part.
  18. */
  19. public static function get_url_part( $url, $part ) {
  20. $url_parts = wp_parse_url( $url );
  21. if ( isset( $url_parts[ $part ] ) ) {
  22. return $url_parts[ $part ];
  23. }
  24. return '';
  25. }
  26. }