User Settings
Azdabundanyanam
○ Çevrimdışı
☀️ Solar Okur
document.addEventListener( 'click', function(e) {
const followBtn = e.target.closest( '[data-follow-user]' );
if (!followBtn) { return; }
const userId = followBtn.getAttribute( 'data-follow-user' );
followBtn.disabled = true;
followBtn.textContent = 'Gönderiliyor...';
const data = new FormData();
data.append( 'action', 'sn_send_follow_request' );
data.append( 'user_id', userId );
data.append( 'nonce', '64d1ee7f36' );
fetch( 'https://solarnovas.net/wp-admin/admin-ajax.php', { method:'POST', body:data } ) .then( response => response.json() ) .then( result => {
if ( result.success ) {
followBtn.textContent = '✓ İstek Gönderildi';
followBtn.classList.remove( 'follow' );
followBtn.classList.add( 'pending' );
} else {
alert( result.data || 'Takip isteği gönderilemedi.' );
followBtn.disabled = false;
followBtn.textContent = '+ Takip Et';
}
} ) .catch( function() {
alert( 'Bir bağlantı hatası oluştu.' );
followBtn.disabled = false;
followBtn.textContent = '+ Takip Et';
} );
} );
/* Takip isteği kabul / red */
document.addEventListener( 'click', function(e) {
const button = e.target.closest( '[data-request-action]' );
if (!button) { return; }
const action = button.getAttribute( 'data-request-action' );
const userId = button.getAttribute( 'data-request-user' );
button.disabled = true;
const data = new FormData();
data.append( 'action', 'sn_handle_follow_request' );
data.append( 'request_action', action );
data.append( 'user_id', userId );
data.append( 'nonce', '64d1ee7f36' );
fetch( 'https://solarnovas.net/wp-admin/admin-ajax.php', { method:'POST', body:data } ) .then( response => response.json() ) .then( result => {
if ( result.success ) {
const item = button.closest( '.sn-request-item' );
if (item) { item.remove(); }
/* Kabul edildiğinde doğrudan DM sayfasını aç */ if ( action === 'accept' && result.data && result.data.dm_url ) { window.location.href = result.data.dm_url; return; }
const count = document.getElementById( 'sn-request-count' );
if (count) {
let current = parseInt( count.textContent ) || 0;
current = Math.max( 0, current - 1 );
count.textContent = current;
}
} else {
alert( result.data || 'İşlem yapılamadı.' );
button.disabled = false;
}
} ) .catch( function() {
alert( 'Bağlantı hatası oluştu.' );
button.disabled = false;
} );
} );