Changeset 3436214
- Timestamp:
- 01/09/2026 06:13:00 PM (3 months ago)
- Location:
- digi-report/trunk
- Files:
-
- 2 edited
-
digi-report.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
digi-report/trunk/digi-report.php
r3436209 r3436214 3 3 Plugin Name: Digi Report 4 4 Description: A plugin that generates and sends WordPress maintenance reports via email (Integrated with Independent Analytics). 5 Version: 2.7. 45 Version: 2.7.5 6 6 Author: DigiPerforma - Marketing Digital [digiperforma.com.br] 7 7 License: GPLv2 or later … … 111 111 </div> 112 112 <?php else: ?> 113 <div class="notice notice-warning inline" style="display:block;"> 114 <p><strong>Status do Analytics:</strong> Erro ao encontrar tabela.</p> 115 <div style="font-size:0.85em; color: #666; background: #fff; padding: 10px; border: 1px solid #ccc; max-height: 200px; overflow: auto;"> 116 <strong>Relatório de Detetive (Debug):</strong><br> 117 1. Nome que tentamos buscar automaticamente: <code><?php echo esc_html($analytics['found_table_views'] ? $analytics['found_table_views'] : 'NENHUMA ENCONTRADA'); ?></code><br> 118 2. Lista de TODAS as tabelas encontradas no seu banco:<br> 119 <pre><?php print_r($analytics['all_tables']); ?></pre> 120 </div> 121 </div> 113 <div class="notice notice-warning inline"><p><strong>Status do Analytics:</strong> Não detectado. Certifique-se de que o plugin <em>Independent Analytics</em> está ativo.</p></div> 122 114 <?php endif; ?> 123 115 … … 143 135 144 136 // ========================================================= 145 // 2. FUNÇÃO: AUTO-DETECÇÃO DE TABELA (SHERLOCK HOLMES)137 // 2. FUNÇÃO: AUTO-DETECÇÃO CORRIGIDA (NOME LONGO) 146 138 // ========================================================= 147 139 function digi_report_get_analytics_data() { 148 140 global $wpdb; 149 141 150 // 1. PROCURA A TABELA CORRETA NO BANCO (Ignorando prefixos padrão)151 // Busca qualquer tabela que termine em 'ia_views'152 $ found_views_table = $wpdb->get_var("SHOW TABLES LIKE '%ia_views'");153 $ found_sessions_table = $wpdb->get_var("SHOW TABLES LIKE '%ia_sessions'");142 // DEFINIÇÃO CORRETA BASEADA NO SEU LOG: 143 // O plugin usa "independent_analytics_views" e não "ia_views" 144 $table_views = $wpdb->prefix . 'independent_analytics_views'; 145 $table_sessions = $wpdb->prefix . 'independent_analytics_sessions'; 154 146 155 147 // Datas (Últimos 30 dias) … … 157 149 $end_date = date('Y-m-d'); 158 150 159 // Se NÃO achou a tabela, retorna erro e lista todas as tabelas para debug 160 if (!$found_views_table) { 161 $all_tables = $wpdb->get_col("SHOW TABLES"); 162 return array( 163 'active' => false, 164 'found_table_views' => null, 165 'all_tables' => $all_tables // Lista completa para você ver o nome real 166 ); 151 // Verifica se a tabela principal existe 152 if ($wpdb->get_var("SHOW TABLES LIKE '$table_views'") != $table_views) { 153 // Fallback: Se não achar o nome longo, tenta o curto (só por garantia) 154 $table_views = $wpdb->prefix . 'ia_views'; 155 $table_sessions = $wpdb->prefix . 'ia_sessions'; 156 157 if ($wpdb->get_var("SHOW TABLES LIKE '$table_views'") != $table_views) { 158 return array('active' => false); 159 } 167 160 } 168 161 169 // Se achou , usa o nome encontrado (seja ele qual for)170 $views = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $ found_views_tableWHERE `date` BETWEEN %s AND %s", $start_date, $end_date));171 $visitors = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $ found_sessions_tableWHERE `date` BETWEEN %s AND %s", $start_date, $end_date));162 // Se achou a tabela, executa as queries 163 $views = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $table_views WHERE `date` BETWEEN %s AND %s", $start_date, $end_date)); 164 $visitors = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $table_sessions WHERE `date` BETWEEN %s AND %s", $start_date, $end_date)); 172 165 173 166 $top_pages = $wpdb->get_results($wpdb->prepare( 174 "SELECT page_path as name, COUNT(*) as views FROM $ found_views_tableWHERE `date` BETWEEN %s AND %s GROUP BY page_path ORDER BY views DESC LIMIT 3",167 "SELECT page_path as name, COUNT(*) as views FROM $table_views WHERE `date` BETWEEN %s AND %s GROUP BY page_path ORDER BY views DESC LIMIT 3", 175 168 $start_date, $end_date 176 169 ), ARRAY_A); 177 170 178 171 $top_cities = $wpdb->get_results($wpdb->prepare( 179 "SELECT city, COUNT(*) as visitors FROM $ found_sessions_tableWHERE `date` BETWEEN %s AND %s AND city != '' GROUP BY city ORDER BY visitors DESC LIMIT 3",172 "SELECT city, COUNT(*) as visitors FROM $table_sessions WHERE `date` BETWEEN %s AND %s AND city != '' GROUP BY city ORDER BY visitors DESC LIMIT 3", 180 173 $start_date, $end_date 181 174 ), ARRAY_A); -
digi-report/trunk/readme.txt
r3436209 r3436214 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 2.7. 46 Stable tag: 2.7.5 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later
Note: See TracChangeset
for help on using the changeset viewer.