Changeset 3376694
- Timestamp:
- 10/11/2025 02:19:01 PM (6 months ago)
- Location:
- maio-the-new-ai-geo-seo-tool/trunk
- Files:
-
- 2 added
- 5 edited
-
js/maio_analytics.js (modified) (1 diff)
-
maio-ai-scanner.php (modified) (8 diffs)
-
maio-analytics-api.php (added)
-
maio-llm-referral-tracking.php (added)
-
maio-main.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
-
scanner-pages/maio-trust-markers.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
maio-the-new-ai-geo-seo-tool/trunk/js/maio_analytics.js
r3325473 r3376694 65 65 if (meterElement.length) meterElement.text(count); 66 66 }); 67 } else {68 console.error('Unexpected response:', response);69 67 } 70 68 }, -
maio-the-new-ai-geo-seo-tool/trunk/maio-ai-scanner.php
r3372753 r3376694 8 8 if (!defined('ABSPATH')) { 9 9 exit; 10 } 11 12 /** 13 * Get API URL based on environment 14 * Automatically detects local Docker development vs production 15 */ 16 function maio_get_api_url() { 17 // Check if explicitly set via environment variable (Docker) 18 $env_api_url = getenv('MAIO_API_URL'); 19 if ($env_api_url !== false && !empty($env_api_url)) { 20 return $env_api_url . '/api/v1/internal/scan/url'; 21 } 22 23 // Check if WordPress constant is defined (manual override) 24 if (defined('MAIO_API_URL')) { 25 return MAIO_API_URL . '/api/v1/internal/scan/url'; 26 } 27 28 // Check if running in Docker (look for docker hostname) 29 if (gethostname() && strpos(gethostname(), 'maio-wordpress') !== false) { 30 return 'http://maio-api:5000/api/v1/internal/scan/url'; 31 } 32 33 // Check if local development (localhost or .local domain) 34 $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; 35 if (strpos($host, 'localhost') !== false || 36 strpos($host, '127.0.0.1') !== false || 37 strpos($host, '.local') !== false) { 38 return 'http://localhost:5000/api/v1/internal/scan/url'; 39 } 40 41 // Default to production 42 return 'https://api.maioai.com/api/v1/internal/scan/url'; 10 43 } 11 44 … … 52 85 wp_enqueue_style('maio-scanner-dashboard', plugins_url('css/maio-scanner-dashboard.css', __FILE__), array(), MAIO_VERSION); 53 86 87 // Determine API URL (local development vs production) 88 $api_url = maio_get_api_url(); 89 54 90 // Localize script with AJAX URL and nonce 55 91 wp_localize_script('maio-ai-scanner', 'maioAIScanner', array( … … 57 93 'nonce' => wp_create_nonce('maio_ai_scanner_nonce'), 58 94 'siteUrl' => get_home_url(), // WordPress site URL (homepage) 59 'apiUrl' => 'https://api.maioai.com/api/v1/internal/scan/url', // Use same API as main plugin95 'apiUrl' => $api_url, // Automatically detects local or production 60 96 'installToken' => 'dummy_plugin_token', // Use same dummy token as main plugin - will be handled by reverse proxy 61 97 'strings' => array( … … 98 134 99 135 136 // Get API URL (automatically detects local or production) 137 $api_url = maio_get_api_url(); 138 100 139 // Call the AI Scanner API 101 $response = wp_remote_post( 'https://api.maioai.com/api/v1/internal/scan/url', array(140 $response = wp_remote_post($api_url, array( 102 141 'headers' => array( 103 142 'X-Install-Token' => 'dummy_plugin_token', // Use same dummy token as main plugin … … 968 1007 969 1008 if ($result) { 970 wp_send_json_success('FAQ Schema added successfully'); 1009 wp_send_json_success([ 1010 'message' => 'FAQ Schema added successfully', 1011 'cache_cleared' => true, 1012 'wait_before_rescan' => 2 // Suggest waiting 2 seconds before rescanning 1013 ]); 971 1014 } else { 972 1015 wp_send_json_error('Failed to add FAQ Schema'); … … 2389 2432 // Add FAQ schema to the homepage 2390 2433 update_option('maio_faq_schema_enabled', true); 2434 2435 // Clear WordPress object cache for this option 2436 if (function_exists('wp_cache_delete')) { 2437 wp_cache_delete('maio_faq_schema_enabled', 'options'); 2438 } 2439 2440 // Force cache flush 2441 if (function_exists('wp_cache_flush')) { 2442 wp_cache_flush(); 2443 } 2444 2391 2445 return true; 2392 2446 } … … 2395 2449 // Remove FAQ schema from the homepage 2396 2450 update_option('maio_faq_schema_enabled', false); 2451 2452 // Clear WordPress object cache for this option 2453 if (function_exists('wp_cache_delete')) { 2454 wp_cache_delete('maio_faq_schema_enabled', 'options'); 2455 } 2456 2457 // Force cache flush 2458 if (function_exists('wp_cache_flush')) { 2459 wp_cache_flush(); 2460 } 2461 2397 2462 return true; 2398 2463 } … … 4943 5008 if (is_admin()) return; // Only output schema on the front-end 4944 5009 5010 // Force fresh option read (bypass cache) 5011 if (function_exists('wp_cache_delete')) { 5012 wp_cache_delete('maio_faq_schema_enabled', 'options'); 5013 } 4945 5014 $faq_enabled = get_option('maio_faq_schema_enabled', false); 4946 5015 -
maio-the-new-ai-geo-seo-tool/trunk/maio-main.php
r3372753 r3376694 4 4 * Plugin URI: https://maioai.com 5 5 * Description: This plugin helps optimize your Website for AI-powered discovery tools such as ChatGPT, Perplexity, Claude, Google Gemini, Google AI Overviews, Meta Llama and many more. It combines the best of traditional SEO and emerging AIO strategies to ensure your brand is accurately and favorably represented in AI-generated content. 6 * Version: 5. 1.396 * Version: 5.2.17 7 7 * Requires at least: 5.0 8 8 * Requires PHP: 7.2 … … 16 16 17 17 // Define plugin constants 18 define('MAIO_VERSION', '5. 1.39');18 define('MAIO_VERSION', '5.2.17'); 19 19 define('MAIO_PLUGIN_DIR', plugin_dir_path(__FILE__)); 20 20 define('MAIO_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 23 23 require_once MAIO_PLUGIN_DIR . 'maio_analytics.php'; 24 24 require_once MAIO_PLUGIN_DIR . 'maio-ai-scanner.php'; 25 require_once MAIO_PLUGIN_DIR . 'maio-analytics-api.php'; // REST API endpoints for dashboard 26 require_once MAIO_PLUGIN_DIR . 'maio-llm-referral-tracking.php'; // LLM referral tracking 25 27 26 28 // Add cache-busting headers … … 1813 1815 // Validate and sanitize inputs 1814 1816 $llm_id = sanitize_text_field(wp_unslash($llm_id)); 1815 $page_url = esc_url_raw(wp_unslash($page_url)); 1817 // DO NOT use esc_url_raw() - it destroys international characters! 1818 // Store URLs with their international characters intact (percent-encoded if needed) 1819 $page_url = wp_unslash($page_url); 1816 1820 $status = sanitize_text_field(wp_unslash($status)); 1817 1821 $response_data = sanitize_text_field(wp_unslash($response_data)); … … 2247 2251 static $maio_crawler_detected = false; 2248 2252 2249 // Early detection before any caching 2250 add_action(' init', function() {2253 // Early detection before any caching (using 'wp' hook for proper $wp->request parsing) 2254 add_action('wp', function() { 2251 2255 // Prevent double logging for admin-ajax requests 2252 2256 // PHP 8.1+ compatibility: ensure REQUEST_URI is not null … … 2262 2266 $llm_info = maio_identify_llm($user_agent); 2263 2267 if ($llm_info) { 2264 $host = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : ''; 2265 $uri = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : ''; 2266 $page_url = (is_ssl() ? 'https://' : 'http://') . $host . $uri; 2268 // Get the current URL preserving international characters 2269 // Use global $wp which has the parsed request 2270 global $wp; 2271 $current_url = home_url($wp->request); 2272 2273 // Add query string if present 2274 if (!empty($_SERVER['QUERY_STRING'])) { 2275 $current_url .= '?' . wp_unslash($_SERVER['QUERY_STRING']); 2276 } 2277 2278 // Add trailing slash if original REQUEST_URI had it 2279 if (!empty($_SERVER['REQUEST_URI']) && substr($_SERVER['REQUEST_URI'], -1) === '/') { 2280 $current_url = trailingslashit($current_url); 2281 } 2282 2283 $page_url = $current_url; 2267 2284 $response_data = json_encode([ 2268 2285 'user_agent' => $user_agent, … … 2293 2310 $ip = isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])) : ''; 2294 2311 $referer = isset($_SERVER['HTTP_REFERER']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_REFERER'])) : ''; 2295 $page_url = isset($_POST['page_url']) ? sanitize_text_field(wp_unslash($_POST['page_url'])) : (isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : ''); 2312 // DO NOT use sanitize_text_field() on REQUEST_URI or page_url - it destroys international characters! 2313 $page_url = isset($_POST['page_url']) ? wp_unslash($_POST['page_url']) : (isset($_SERVER['REQUEST_URI']) ? wp_unslash($_SERVER['REQUEST_URI']) : ''); 2296 2314 2297 2315 $ua = strtolower($user_agent); -
maio-the-new-ai-geo-seo-tool/trunk/readme.txt
r3372753 r3376694 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8.2 6 Stable tag: 5. 1.396 Stable tag: 5.2.17 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 38 38 39 39 == Changelog == 40 41 = 5.2.17 = 42 * Added infrastructure for future MAIO smart web dashboard analytics 40 43 41 44 = 5.1.39 = -
maio-the-new-ai-geo-seo-tool/trunk/scanner-pages/maio-trust-markers.php
r3368559 r3376694 308 308 }, 309 309 error: function(xhr, status, error) { 310 console.error('AJAX Error:', error);311 310 alert('Error: Failed to apply improvement. Please try again.'); 312 311 $button.prop('disabled', false).text($button.data('original-text') || 'Try Again');
Note: See TracChangeset
for help on using the changeset viewer.