/** * Get the user's information * * @return array **/ function kp_getUserData() { // Get the user from the visit table (if they exist) $ip = kp_determineIP(); // Trim the ip if they passed an invalid address if (strlen($ip) > 63) { $ip = substr($ip, 0, 63); } // We get the user agent and save it so we can ignore bots in our recommendations $ua = ""; if (isset($_SERVER["HTTP_USER_AGENT"])) { $ua = $_SERVER["HTTP_USER_AGENT"]; if (strlen($ua) > 127) { $ua = substr($ua, 0, 127); } } return array("ip" => $ip, "ua" => $ua); }
/** * * The following functions render each box on the setting page * **/ function kp_advancedSettingsBox() { $kp_Tracking = get_option("kp_Tracking", "none"); $kp_TrackingCode = get_option("kp_TrackingCode", ""); $kp_BlockedIps = get_option("kp_BlockedIps", ""); if ($kp_BlockedIps == __("xxx.xxx.xxx.xxx # Example IP Address")) { $kp_BlockedIps = ""; } ?> <div id="advancedSettingsBox" class="postbox"> <h3 class="hndle" style="font-size:15px; padding:7px 10px 7px 10px; cursor:default;"><span><?php _e("Advanced Settings"); ?> </span></h3> <div class="inside"> <form method="post" action="options.php"> <?php settings_fields("kp_advancedSettings"); // Outputs a nonce for the form ?> <div> <input type="radio" name="kp_Tracking" value="none"<?php checked($kp_Tracking == "none"); ?> id="kp_Tracking-none" /> <label for="kp_Tracking-none"><?php _e("Do not track clicks on recommended posts with analytics"); ?> </label> </div> <div> <input type="radio" name="kp_Tracking" value="custom"<?php checked($kp_Tracking == "custom"); ?> id="kp_Tracking-custom" /> <label for="kp_Tracking-custom"><?php _e("Analytics tracking code"); ?> </label> <input type="text" name="kp_TrackingCode" value="<?php echo $kp_TrackingCode; ?> " id="kp_TrackingCode" style="width:50%;" onkeyup="kp_removeDoubleQuotes(this);" /> <script type="text/javascript"> function kp_removeDoubleQuotes(elem) { elem.value = elem.value.replace('"', "'"); } </script> <div style="display:inline;"> <a href="#" id="OptionalInformationShowLink" onclick="this.style.display = 'none'; document.getElementById('OptionalInformationShowLink').style.display = 'none'; document.getElementById('OptionalInformationHideDiv').style.display = 'block'; document.getElementById('OptionalInformationHideLink').style.display = 'inline'; return false;" style="display:inline;"><?php _e("What is this?"); ?> </a> <a href="#" id="OptionalInformationHideLink" onclick="this.style.display= 'none'; document.getElementById('OptionalInformationHideDiv').style.display = 'none'; document.getElementById('OptionalInformationShowLink').style.display = 'inline'; return false;" style="display:none;"><?php _e("Hide"); ?> </a> </div> <div id="OptionalInformationHideDiv" style="margin-left:25px; display:none;"> <?php _e("Tracking code is added to the onclick event for links. For example, for Google Analytics use: <pre>try { _gaq.push(['_trackEvent', '" . __('Kindred Posts') . "', '" . __("Click") . "', '{post_slug}']); } catch (e) {}; </pre><div>You can track the following information:<ul style=\"margin-left:15px;\"><li>{post_id}: The id of the post</li><li>{post_url}: The permalink of the post</li><li>{post_title}: The title of the post</li><li>{post_author}: The author of the post</li><li>{post_slug}: A url friendly version of {post_title}</li></ul></div>"); ?> </div> <div style="margin-left:25px;"> <?php _e("NOTE: You can only use single quotes within the tracking code."); ?> </div> </div> <h4><label for="kp_BlockedIps"><?php _e("Ignore visits from the following IP Addresses"); ?> </label></h4> <ol> <li><?php _e("Only put one IP Address per line"); ?> </li> <li><?php _e("You can add comments by putting a # after the IP Address"); ?> </li> </ol> <textarea name="kp_BlockedIps" id="kp_BlockedIps" rows="5" style="width:100%;" placeholder="<?php _e("xxx.xxx.xxx.xxx # Example IP Address"); ?> "><?php echo $kp_BlockedIps; ?> </textarea><br /> <?php _e("Your current IP Address is " . kp_determineIP()); ?> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e("Save Changes"); ?> " /> </p> </form> </div> </div> <?php }