/* * Smart Link - buenosconsejos.net/go/ * Destino: articulos aleatorios de crm.buenosconsejos.net */ add_action('template_redirect', function () { if (is_admin() || wp_doing_ajax()) { return; } $host = strtolower( explode(':', $_SERVER['HTTP_HOST'] ?? '')[0] ); $path = parse_url( $_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH ); $path = trailingslashit( '/' . trim((string) $path, '/') ); // Solo actuar en el dominio principal /go/ if ( !in_array($host, [ 'buenosconsejos.net', 'www.buenosconsejos.net' ], true) || $path !== '/go/' ) { return; } // Evitar cache de redirecciones if (!defined('DONOTCACHEPAGE')) { define('DONOTCACHEPAGE', true); } nocache_headers(); header( 'Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true ); $home = 'https://crm.buenosconsejos.net/'; $hostname = 'crm.buenosconsejos.net'; // Obtener entradas publicadas de CRM $posts = get_transient('smartlink_main_crm_posts'); if (!is_array($posts) || empty($posts)) { $response = wp_remote_get( $home . 'wp-json/wp/v2/posts?per_page=100&status=publish&_fields=link', [ 'timeout' => 8, 'headers' => [ 'Accept' => 'application/json' ] ] ); $posts = []; if ( !is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200 ) { $data = json_decode( wp_remote_retrieve_body($response), true ); if (is_array($data)) { foreach ($data as $post) { $url = $post['link'] ?? ''; $parts = wp_parse_url($url); if ( is_array($parts) && ($parts['scheme'] ?? '') === 'https' && ($parts['host'] ?? '') === $hostname && !empty($parts['path']) && $parts['path'] !== '/' ) { $posts[] = $url; } } } } $posts = array_values(array_unique($posts)); if (!empty($posts)) { set_transient( 'smartlink_main_crm_posts', $posts, 120 ); } } // Si la API falla, enviar a la portada CRM if (empty($posts)) { wp_redirect($home, 302); exit; } // Evitar repetir la ultima entrada $last = isset($_COOKIE['main_crm_last']) ? wp_unslash($_COOKIE['main_crm_last']) : ''; $available = array_values(array_filter( $posts, function ($url) use ($last) { return $url !== $last; } )); if (empty($available)) { $available = $posts; } // Elegir articulo aleatorio $destination = $available[array_rand($available)]; setcookie( 'main_crm_last', $destination, [ 'expires' => time() + 86400, 'path' => '/go/', 'secure' => is_ssl(), 'httponly' => true, 'samesite' => 'Lax' ] ); // Redireccion temporal sin cache wp_redirect($destination, 302); exit; }, 1);

EDITORIAL POLICY

Editorial Policy

At SXZBest, we are committed to providing clear, accurate, and trustworthy financial information.

Content Creation

Our articles are researched using reliable sources, including financial publications, official company websites, and publicly available data.

We aim to simplify complex financial topics so readers can better understand investing, budgeting, and financial planning.

Accuracy and Updates

We strive to keep our content accurate and up to date. However, financial markets and regulations may change over time. Readers are encouraged to verify important financial decisions with qualified professionals.

No Financial Advice

SXZBest does not provide professional financial, legal, or tax advice. All content is intended for informational and educational purposes only.

Editorial Independence

Our editorial decisions are independent of advertisers and affiliate relationships. We maintain strict separation between advertising and content.

Contact

If you notice inaccuracies or would like to provide feedback, please contact:

contact@sxzbest.xyz