
// ==============================================================================================
// INICIO: API REST PARA EL NUEVO FRONTEND REACT (BETA.GAYPERU.PE)
// ==============================================================================================

// 1. Obligar a la API a enviar a todos los usuarios (no solo a los autores de posts)
add_filter('rest_user_query', function($prepared_args, $request) {
    if (isset($prepared_args['has_published_posts'])) {
        unset($prepared_args['has_published_posts']);
    }
    return $prepared_args;
}, 10, 2);

// 2. Exponer fotos reales y metas personalizados a React
add_filter('rest_prepare_user', function($response, $user, $request) {
    $user_id = $user->ID;

    // A. Extracción de foto idéntica a gp_expose_global_and_chat_data
    $foto_url = '';
    $foto_meta = get_user_meta( $user_id, 'gp_foto_perfil', true );
    if ( $foto_meta && is_numeric($foto_meta) ) {
        $foto_url = wp_get_attachment_url( $foto_meta );
    }
    if ( empty($foto_url) ) {
        $avatar_ajax = get_user_meta( $user_id, 'gp_avatar', true );
        if ($avatar_ajax) {
            $foto_url = is_numeric($avatar_ajax) ? wp_get_attachment_url($avatar_ajax) : $avatar_ajax;
        }
    }
    if ( empty($foto_url) ) {
        $um_foto = get_user_meta($user_id, 'profile_photo', true);
        if ($um_foto) {
            $foto_url = (strpos($um_foto, 'http') === 0) ? $um_foto : site_url(ltrim($um_foto, '/'));
        }
    }
    if ( empty($foto_url) ) {
        $foto_url = get_avatar_url( $user_id, array('size' => 300) );
    }

    // B. Inyectar datos a la API
    $response->data['gp_foto_url'] = $foto_url;
    
    $age = get_user_meta( $user_id, 'gp_age', true );
    if ( empty($age) ) { $age = get_user_meta( $user_id, 'gp_edad', true ); }
    $response->data['gp_edad'] = $age;
    
    $district = get_user_meta( $user_id, 'gp_district', true );
    if ( empty($district) ) { $district = get_user_meta( $user_id, 'gp_distrito', true ); }
    if ( empty($district) ) { $district = get_user_meta( $user_id, 'gp_city', true ); }
    if ( empty($district) ) { $district = get_user_meta( $user_id, 'gp_ciudad', true ); }
    $response->data['gp_distrito'] = $district;
    
    $response->data['gp_genero'] = get_user_meta($user_id, 'gp_genero', true);
    
    $role = get_user_meta( $user_id, 'gp_rol', true );
    if ( empty($role) ) { $role = get_user_meta( $user_id, 'rol', true ); }
    if ( empty($role) ) { $role = get_user_meta( $user_id, 'gp_role', true ); }
    if ( empty($role) ) { $role = get_user_meta( $user_id, 'role', true ); }
    $response->data['gp_rol'] = $role;

    return $response;
}, 10, 3);
// ==============================================================================================
// FIN: API REST PARA EL NUEVO FRONTEND REACT
// ==============================================================================================

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//gayperu.pe/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://gayperu.pe/post-sitemap.xml</loc>
		<lastmod>2026-08-18T02:49:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/post-sitemap2.xml</loc>
		<lastmod>2026-08-18T02:49:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/page-sitemap.xml</loc>
		<lastmod>2026-08-17T22:17:07+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/tdb_templates-sitemap.xml</loc>
		<lastmod>2025-04-04T22:13:22+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/mailpoet_page-sitemap.xml</loc>
		<lastmod>2024-12-18T11:51:13+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/category-sitemap.xml</loc>
		<lastmod>2026-08-18T02:49:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/post_tag-sitemap.xml</loc>
		<lastmod>2026-08-18T02:49:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/post_tag-sitemap2.xml</loc>
		<lastmod>2026-08-18T02:49:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://gayperu.pe/post_tag-sitemap3.xml</loc>
		<lastmod>2026-08-15T09:12:10+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->