Changeset 3408647
- Timestamp:
- 12/03/2025 12:40:08 AM (4 months ago)
- Location:
- searchify-ai
- Files:
-
- 4 added
- 2 edited
-
tags/1.1.0 (added)
-
tags/1.1.0/LICENSE.txt (added)
-
tags/1.1.0/README.txt (added)
-
tags/1.1.0/searchify-tracker.php (added)
-
trunk/README.txt (modified) (5 diffs)
-
trunk/searchify-tracker.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
searchify-ai/trunk/README.txt
r3407116 r3408647 5 5 Requires at least: 5.0 6 6 Tested up to: 6.9 7 Stable tag: 1. 0.07 Stable tag: 1.1.0 8 8 License: GPLv2 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 13 13 == Description == 14 14 15 Searchify Tracker automatically sends request data from your WordPress site to the Searchify API. 15 Searchify Tracker automatically sends request data from your WordPress site to the Searchify API. 16 16 This helps you understand how your content is being cited and referenced across the web in AI conversations. 17 17 … … 32 32 1. Upload the plugin files to the `/wp-content/plugins/searchify-tracker` directory, or install directly from the WordPress plugins screen. 33 33 2. Activate the plugin through the 'Plugins' screen in WordPress. 34 3. That ’s it! Tracking starts automatically.34 3. That's it! Tracking starts automatically. 35 35 36 36 == Frequently Asked Questions == 37 37 38 = Does the plugin modify my site's content? = 39 No. The plugin does not modify or alter your website's content in any way. 40 38 41 = Does this plugin slow down my site? = 39 No. Tracking requests are sent asynchronously and do not delay page loading.42 The plugin may add a minimal delay (less than 1 second) while sending data. 40 43 41 44 = What data is sent? = … … 47 50 == Changelog == 48 51 52 = 1.1.0 = 53 * Improved tracking reliability with multiple WordPress hooks 54 * Added output buffering support for cached pages 55 49 56 = 1.0 = 50 57 * Initial release … … 52 59 == Upgrade Notice == 53 60 61 = 1.1.0 = 62 Improved tracking reliability and security fixes. No action required. 63 54 64 = 1.0 = 55 65 Initial release. 66 -
searchify-ai/trunk/searchify-tracker.php
r3368070 r3408647 3 3 Plugin Name: Searchify AI 4 4 Description: Tracks live citations from AI conversations. 5 Version: 1. 0.05 Version: 1.1.0 6 6 Author: Searchify 7 7 Author URI: https://searchify.ai/ … … 9 9 */ 10 10 11 add_action('init', 'searchify_track_request'); 11 // Define tracking function 12 if (!function_exists('searchify_track_request')) { 13 function searchify_track_request() { 14 // Avoid tracking admin, cron, or AJAX requests 15 if (is_admin() || wp_doing_cron() || wp_doing_ajax()) { 16 return; 17 } 12 18 13 function searchify_track_request() { 14 // Avoid tracking admin, cron, or AJAX requests 15 if (is_admin() || wp_doing_cron() || wp_doing_ajax()) { 16 return; 19 // Avoid duplicate tracking by checking if we've already tracked this request 20 static $tracked = false; 21 if ($tracked) { 22 return; 23 } 24 $tracked = true; 25 26 // Collect and sanitize request info 27 $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; 28 29 $host = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : ''; 30 $uri = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : ''; 31 $full_url = esc_url_raw($scheme . '://' . $host . $uri); 32 33 $domain = $host; // already sanitized 34 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) 35 ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) 36 : 'unknown'; 37 38 $data = array( 39 'full_url' => $full_url, 40 'domain' => $domain, 41 'user_agent' => $user_agent, 42 ); 43 44 // Send POST request to API 45 // Use blocking with short timeout to ensure request completes before PHP exits 46 // Short timeout (1s) minimizes page load impact while ensuring delivery 47 wp_remote_post( 48 'https://api.searchify.ai/v1/track/citation', 49 array( 50 'headers' => array('Content-Type' => 'application/json'), 51 'body' => wp_json_encode($data), 52 'timeout' => 1, // Short timeout to minimize delay 53 'blocking' => true, // Blocking ensures request completes before PHP exits 54 ) 55 ); 56 17 57 } 58 } 18 59 19 // Collect and sanitize request info 20 $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; 60 // Start output buffering immediately to ensure we can track even cached pages 61 if (!headers_sent() && !ob_get_level()) { 62 ob_start('searchify_output_buffer_handler'); 63 } 21 64 22 $host = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : ''; 23 $uri = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : ''; 24 $full_url = esc_url_raw($scheme . '://' . $host . $uri); 65 // Track on the earliest possible hooks - before any caching logic 66 // These fire in order: muplugins_loaded -> plugins_loaded -> init -> setup_theme -> template_redirect 67 add_action('muplugins_loaded', 'searchify_track_request', 1); 68 add_action('plugins_loaded', 'searchify_track_request', 1); 69 add_action('init', 'searchify_track_request', 1); 70 add_action('setup_theme', 'searchify_track_request', 1); 71 add_action('template_redirect', 'searchify_track_request', 1); 25 72 26 $domain = $host; // already sanitized 27 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) 28 ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) 29 : 'unknown'; 73 // Track on shutdown hook - ALWAYS fires if PHP executes at all 74 add_action('shutdown', 'searchify_track_request', 999); 30 75 31 $data = array(32 'full_url' => $full_url,33 'domain' => $domain,34 'user_agent' => $user_agent,35 );36 76 37 // Send POST request to API 38 wp_remote_post( 39 'https://api.searchify.ai/v1/track/citation', 40 array( 41 'headers' => array('Content-Type' => 'application/json'), 42 'body' => wp_json_encode($data), 43 'timeout' => 1, 44 'blocking' => true, 45 ) 46 ); 77 /** 78 * Output buffer handler - ensures tracking happens even with output buffering 79 */ 80 function searchify_output_buffer_handler($buffer) { 81 // Track when buffer is processed 82 searchify_track_request(); 83 return $buffer; // Return buffer unchanged 47 84 }
Note: See TracChangeset
for help on using the changeset viewer.