| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/StockAdjust/wp-content/plugins/wp-user-avatar/src/Classes/ |
Upload File : |
<?php
namespace ProfilePress\Core\Classes;
/**
* Rewrite the profile page URL
*
* Rewrite the page URL to contain the "/profile" slug
*/
class ProfileUrlRewrite
{
/** @type object instance */
private static $instance;
public function __construct()
{
add_action('init', array($this, 'rewrite_function'), 10, 0);
}
public function rewrite_function()
{
// set $page_id to the WordPress page with the profile shortcode
$page_id = apply_filters('ppress_profile_page_id', ppress_get_setting('set_user_profile_shortcode'));
if ( ! empty($page_id)) {
$profile_slug = ppress_get_profile_slug();
add_rewrite_tag('%who%', '([^&]+)');
$regex_1 = apply_filters('ppress_profile_rewrite_regex_1', "^{$profile_slug}/([^/]*)/?", $profile_slug);
$regex_2 = apply_filters('ppress_profile_rewrite_regex_2', "^{$profile_slug}/?$", $profile_slug);
$query_1 = apply_filters('ppress_profile_rewrite_query_1', 'index.php?page_id=' . $page_id . '&who=$matches[1]', $page_id);
$query_2 = apply_filters('ppress_profile_rewrite_query_2', 'index.php?page_id=' . $page_id, $page_id);
add_rewrite_rule($regex_1, $query_1, 'top');
add_rewrite_rule($regex_2, $query_2, 'top');
do_action('ppress_after_rewrite_hook_added', $profile_slug, $page_id);
}
}
public static function get_instance()
{
if ( ! self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
}