Skip to content

Instantly share code, notes, and snippets.

@amarinediary
amarinediary / wpso_50761584.php
Last active January 22, 2022 23:04
Retrieves the current permalink (WordPress, Woocommerce)
<?php
/**
* Retrieves the current permalink.
* Filters-out unregistered query variables through WordPress core get_query_var() function.
* Make it safe to use in database queries, redirects and HTTP requests through WordPress core esc_url_raw() function.
*
* @param String $args['relative'] (true|false), Relative path if true. Default to false.
*
* @return String Relative or absolute path to the current permalink.