$ano = trim(sanitize_text_field($_POST['ano'] ?? '')); $doi = trim(sanitize_text_field($_POST['doi'] ?? '')); $page = max(1, intval($_POST['page'] ?? 1)); $per = max(1, min(50, intval($_POST['per'] ?? 10))); $off = ($page - 1) * $per; $w = array(); $p = array(); if ($q !== '') { $like = '%' . $wpdb->esc_like($q) . '%'; $w[] = '(titulo LIKE %s OR autores LIKE %s)'; $p[] = $like; $p[] = $like; } if ($issn !== '') { $w[] = 'issn = %s'; $p[] = $issn; } if ($revista !== '') { $w[] = 'revista LIKE %s'; $p[] = '%' . $wpdb->esc_like($revista) . '%'; } if ($ano !== '') { $w[] = 'ano = %d'; $p[] = (int)$ano; } if ($doi !== '') { $w[] = 'doi LIKE %s'; $p[] = '%' . $wpdb->esc_like($doi) . '%'; } $where = $w ? ('WHERE ' . implode(' AND ', $w)) : ''; $count_sql = "SELECT COUNT(*) FROM {$this->tb_artigos} {$where}"; $count = $p ? (int)$wpdb->get_var($wpdb->prepare($count_sql, $p)) : (int)$wpdb->get_var($count_sql); $pages = max(1, (int)ceil($count / $per)); $sql = "SELECT id,titulo,autores,doi,revista,issn,ano,volume,numero,paginas,pdf,created_at,link FROM {$this->tb_artigos} {$where} ORDER BY created_at DESC, id DESC LIMIT %d OFFSET %d"; $p2 = $p; $p2[] = $per; $p2[] = $off; $rows = $wpdb->get_results($wpdb->prepare($sql, $p2), ARRAY_A); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if (empty($rows)) { $html .= ''; } else { foreach ($rows as $r) { $titulo = esc_html($r['titulo']); if (!empty($r['link'])) { $titulo = '' . $titulo . ''; } $doi_val = trim($r['doi']); if ($doi_val !== '') { $doi_url = (strpos($doi_val, 'http') === 0) ? $doi_val : 'https://doi.org/' . $doi_val; $doi_html = '' . esc_html($doi_val) . ''; } else { $doi_html = ''; } $autores = esc_html(wp_html_excerpt($r['autores'], 80, '…')); $pdf_html = ''; if (!empty($r['pdf'])) { $pdf_html = 'PDF'; } $html .= '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . ''; } } $html .= '
IDTítuloAutoresDOIRevistaISSNAnoVol.Núm.PáginasPDFCriado
(nenhum resultado)
' . intval($r['id']) . '' . $titulo . '' . $autores . '' . $doi_html . '' . esc_html($r['revista']) . '' . esc_html($r['issn']) . '' . esc_html($r['ano']) . '' . esc_html($r['volume']) . '' . esc_html($r['numero']) . '' . esc_html($r['paginas']) . '' . $pdf_html . '' . esc_html($r['created_at']) . '
'; wp_send_json_success(array( 'html' => $html, 'count' => $count, 'pages' => $pages, )); } } } new Arauto_Public_300(); https://arautoindex.com/wp-sitemap-posts-post-1.xmlhttps://arautoindex.com/wp-sitemap-posts-page-1.xmlhttps://arautoindex.com/wp-sitemap-taxonomies-category-1.xmlhttps://arautoindex.com/wp-sitemap-users-1.xml