PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/broken-link-checker/includes/survey.php

https://bitbucket.org/lgorence/quickpress
PHP | 58 lines | 36 code | 9 blank | 13 comment | 5 complexity | 1d309219e050024eb40c40edf8bc07a9 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * @author Janis Elsts
  4. * @copyright 2010
  5. */
  6. //Appearify the survey notice to people who have used BLC for at least 2 weeks (doesn't need to be very accurate)
  7. $blc_config = blc_get_configuration();
  8. $blc_show_survey = empty($blc_config->options['hide_surveyio_notice'])
  9. && !empty($blc_config->options['first_installation_timestamp'])
  10. && ( time() - $blc_config->options['first_installation_timestamp'] > 2*7*24*60*60 );
  11. if ( $blc_show_survey ){
  12. add_action('admin_notices', 'blc_display_survey_notice');
  13. }
  14. /**
  15. * Display a notice asking the user to take the Broken Link Checker user survey.
  16. *
  17. * @return void
  18. */
  19. function blc_display_survey_notice(){
  20. //Only people who can actually use the plugin will see the notice
  21. if ( !current_user_can('manage_links') ) return;
  22. if ( !empty($_GET['dismiss-blc-survey']) ){
  23. //The user has chosen to hide the survey notice
  24. $blc_config = blc_get_configuration();
  25. $blc_config->options['hide_surveyio_notice'] = true;
  26. $blc_config->save_options();
  27. return;
  28. }
  29. $survey_url = 'http://survey.io/survey/7fbf0';
  30. $msg = sprintf(
  31. '<strong>Help improve Broken Link Checker - <a href="%s" target="_blank" title="This link will open in a new window" id="blc-take-survey-link">take a user feedback survey!</a></strong>
  32. <br><a href="%s">Hide this notice</a>',
  33. $survey_url,
  34. add_query_arg('dismiss-blc-survey', 1)
  35. );
  36. echo '<div id="update-nag" class="blc-survey-notice" style="text-align: left; padding-left: 10px;">'.$msg.'</div>';
  37. //Auto-hide the notice after the user clicks the survey link
  38. ?>
  39. <script type="text/javascript">
  40. jQuery(function($){
  41. $('#blc-take-survey-link').click(function(){
  42. $('.blc-survey-notice').hide('fast');
  43. $.get('<?php echo esc_js(add_query_arg('dismiss-blc-survey', 1, admin_url())); ?>');
  44. });
  45. });
  46. </script>
  47. <?php
  48. }
  49. ?>