Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

115 lignes
2.8 KiB

  1. <?php
  2. /**
  3. * @package Akismet
  4. */
  5. class Akismet_Widget extends WP_Widget {
  6. function __construct() {
  7. load_plugin_textdomain( 'akismet' );
  8. parent::__construct(
  9. 'akismet_widget',
  10. __( 'Akismet Widget' , 'akismet'),
  11. array( 'description' => __( 'Display the number of spam comments Akismet has caught' , 'akismet') )
  12. );
  13. if ( is_active_widget( false, false, $this->id_base ) ) {
  14. add_action( 'wp_head', array( $this, 'css' ) );
  15. }
  16. }
  17. function css() {
  18. ?>
  19. <style type="text/css">
  20. .a-stats {
  21. width: auto;
  22. }
  23. .a-stats a {
  24. background: #7CA821;
  25. background-image:-moz-linear-gradient(0% 100% 90deg,#5F8E14,#7CA821);
  26. background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#7CA821),to(#5F8E14));
  27. border: 1px solid #5F8E14;
  28. border-radius:3px;
  29. color: #CFEA93;
  30. cursor: pointer;
  31. display: block;
  32. font-weight: normal;
  33. height: 100%;
  34. -moz-border-radius:3px;
  35. padding: 7px 0 8px;
  36. text-align: center;
  37. text-decoration: none;
  38. -webkit-border-radius:3px;
  39. width: 100%;
  40. }
  41. .a-stats a:hover {
  42. text-decoration: none;
  43. background-image:-moz-linear-gradient(0% 100% 90deg,#6F9C1B,#659417);
  44. background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#659417),to(#6F9C1B));
  45. }
  46. .a-stats .count {
  47. color: #FFF;
  48. display: block;
  49. font-size: 15px;
  50. line-height: 16px;
  51. padding: 0 13px;
  52. white-space: nowrap;
  53. }
  54. </style>
  55. <?php
  56. }
  57. function form( $instance ) {
  58. if ( $instance ) {
  59. $title = $instance['title'];
  60. }
  61. else {
  62. $title = __( 'Spam Blocked' , 'akismet' );
  63. }
  64. ?>
  65. <p>
  66. <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:' , 'akismet'); ?></label>
  67. <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
  68. </p>
  69. <?php
  70. }
  71. function update( $new_instance, $old_instance ) {
  72. $instance['title'] = strip_tags( $new_instance['title'] );
  73. return $instance;
  74. }
  75. function widget( $args, $instance ) {
  76. $count = get_option( 'akismet_spam_count' );
  77. if ( ! isset( $instance['title'] ) ) {
  78. $instance['title'] = __( 'Spam Blocked' , 'akismet' );
  79. }
  80. echo $args['before_widget'];
  81. if ( ! empty( $instance['title'] ) ) {
  82. echo $args['before_title'];
  83. echo esc_html( $instance['title'] );
  84. echo $args['after_title'];
  85. }
  86. ?>
  87. <div class="a-stats">
  88. <a href="https://akismet.com" target="_blank" title=""><?php printf( _n( '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', $count , 'akismet'), number_format_i18n( $count ) ); ?></a>
  89. </div>
  90. <?php
  91. echo $args['after_widget'];
  92. }
  93. }
  94. function akismet_register_widgets() {
  95. register_widget( 'Akismet_Widget' );
  96. }
  97. add_action( 'widgets_init', 'akismet_register_widgets' );