/misc/tracking.php

  1. <?php 
  2. /** 
  3. * on deactivation, if tracking is on, it will send info to plugin authors that the plugin is no longer active 
  4. */ 
  5. define( 'CF7_STYLE_PLUGIN_PATH', WP_PLUGIN_DIR . '/contact-form-7-style/' ); 
  6. if ( !function_exists( 'cf7_style_announce_authors_about_deactivation' ) ) { 
  7. function cf7_style_announce_authors_about_deactivation () { 
  8. $allowedornot = get_option( 'cf7_style_allow_tracking' ); 
  9. if( '1' == $allowedornot) { 
  10. cf7style_send_tracking_info( $allowedornot, '1' ); 
  11.  
  12. register_deactivation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_deactivation' ); 
  13. /** 
  14. * on activation, if tracking is on, it will send info to plugin authors that the plugin is active. 
  15. */ 
  16. if ( !function_exists( 'cf7_style_announce_authors_about_activation' ) ) { 
  17. function cf7_style_announce_authors_about_activation () { 
  18. $allowedornot = get_option( 'cf7_style_allow_tracking' ); 
  19. if( '1' == $allowedornot) { 
  20. cf7style_send_tracking_info( $allowedornot, '1' ); 
  21. register_activation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_activation' ); 
  22. /** 
  23. * enque pointer  
  24. */ 
  25. if ( !function_exists( 'cf7_style_tracking_enque_script' ) ) { 
  26. add_action( 'admin_enqueue_scripts', 'cf7_style_tracking_enque_script' ); 
  27. function cf7_style_tracking_enque_script() { 
  28. $activeordismiss = get_option( 'cf7_style_allow_tracking' ); 
  29. if ( $activeordismiss !== '0' && $activeordismiss !== '1' ) { 
  30. wp_enqueue_style( 'wp-pointer' ); 
  31. wp_enqueue_script( 'wp-pointer' ); 
  32. add_action( 'admin_print_footer_scripts', 'cf7_style_print_tooltip' ); 
  33.  
  34. /** 
  35. * prints the tooltip 
  36. */ 
  37. if ( !function_exists( 'cf7_style_print_tooltip' ) ) { 
  38. function cf7_style_print_tooltip() { 
  39. $pointer_content = '<h3>'.__( "Thank You for choosing<br/>Contact Form 7 Style!", "contact-form-7-style" ).'</h3>'; 
  40. $pointer_content .= '<p>'.__( "Want to help make CF7 Style even more better? Allow Us to collect non-sensitive diagnostic data.", "contact-form-7-style" ).'</p>'; 
  41. $pointer_content .= '<p>'.__( "We will only collect your website URL, WordPress version, CF7Style plugin version and active status.", "contact-form-7-style" ).'</p>'; 
  42. $pointer_content .= '<p><label>'.__( "Allow collecting data:", "contact-form-7-style" ).'<input id="cf7_style_allow_tracking" type="checkbox" checked="checked" value="1" name="cf7_style_allow_tracking" /></label> </p>'; ?> 
  43. <script type="text/javascript"> 
  44. //<![CDATA[ 
  45. jQuery(document).ready( function($) { 
  46. $('.menu-icon-cf7_style').eq(0).pointer({ 
  47. pointerClass: 'cf7style-pointer',  
  48. content: '<?php echo $pointer_content; ?>',  
  49. position: 'left',  
  50. close: function() { 
  51. $('.cf7style-pointer').hide(); 
  52. return false; 
  53. }).pointer('open'); 
  54. }); 
  55. //]]> 
  56. </script> 
  57. <style type="text/css"> 
  58. .cf7style-pointer .wp-pointer-arrow { 
  59. top: 20px;  
  60. left: -1px; 
  61. </style> 
  62. <?php 
  63.  
  64. /** 
  65. * allow tracking set option 
  66. */ 
  67. if ( !function_exists( 'cf7_style_allow_tracking' ) ) { 
  68. function cf7_style_allow_tracking() { 
  69. if ( $_POST['action'] == 'cf7_style_allow_tracking' ) { 
  70. if ( !is_numeric( $_POST['cf7_style_allow_tracking'] ) ) { 
  71. die(); 
  72. $allowedornot = $_POST['cf7_style_allow_tracking']; 
  73. if ( $allowedornot == '1' ) { 
  74. update_option( 'cf7_style_allow_tracking', '1' ); 
  75. cf7style_send_tracking_info( $allowedornot, '1' ); 
  76. die(); 
  77. add_action( 'wp_ajax_cf7_style_allow_tracking', 'cf7_style_allow_tracking' ); 
  78. if ( !function_exists( 'cf7_style_show_tracking' ) ) { 
  79. function cf7_style_show_tracking() { 
  80. if ( $_POST['action'] == 'cf7_style_show_tracking' ) { 
  81. if ( !is_numeric( $_POST['cf7_style_allow_tracking'] ) ) { 
  82. die(); 
  83. $allowedornot = $_POST['cf7_style_allow_tracking']; 
  84. if ( $allowedornot == '0' ) { 
  85. update_option( 'cf7_style_allow_tracking', '0' ); 
  86. die(); 
  87. add_action( 'wp_ajax_cf7_style_show_tracking', 'cf7_style_show_tracking' ); 
  88.  
  89.  
  90. /** 
  91. * send traciking info function 
  92. */ 
  93. if ( !function_exists( 'cf7style_send_tracking_info' ) ) { 
  94. function cf7style_send_tracking_info( $allowedornot, $activated ) { 
  95. $url = 'http://cf7style.com/tracking/index.php'; 
  96. $plugin_folder = get_plugins( '/' . 'contact-form-7-style' ); 
  97. $plugin_file = 'cf7-style.php'; 
  98. $plugindata = $plugin_folder[$plugin_file]['Version']; 
  99. $multi = ( is_multisite() ? '1' : '0' ); 
  100. $data = array ( 
  101. 'allowed' => $allowedornot,  
  102. 'wpversion' => get_bloginfo('version'),  
  103. 'styleversion' => $plugindata,  
  104. 'siteurl' => site_url(),  
  105. 'multisite' => $multi,  
  106. 'activated' => $activated 
  107. ); 
  108. if(function_exists('curl_version')) { 
  109. $cf7curl = curl_init(); 
  110. $Curl = $url.'?method=withstyle&data='.base64_encode(json_encode($data)).'&format=json'; 
  111. $curlconfig = array (  
  112. CURLOPT_URL => $Curl,  
  113. CURLOPT_RETURNTRANSFER => true 
  114. ); 
  115. curl_setopt_array( $cf7curl, $curlconfig ); 
  116. $output = curl_exec($cf7curl); 
  117. curl_close($cf7curl); 
.