PluginProbe ʕ •ᴥ•ʔ
Akismet Anti-spam: Spam Protection / 5.7
Akismet Anti-spam: Spam Protection v5.7
5.7 3.0.4 3.0.5 3.1 3.1.1 3.1.10 3.1.11 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2 3.3 3.3.1 3.3.2 3.3.3 3.3.4 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 5.0 5.0.1 5.0.2 5.1 5.2 5.3 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.4 5.5 5.6 trunk 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.4.0 2.4.1 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 3.0.0 3.0.0-RC1 3.0.1 3.0.2 3.0.3
akismet / class.akismet-widget.php
akismet Last commit date
_inc 1 month ago abilities 1 month ago views 1 month ago .htaccess 1 month ago LICENSE.txt 10 years ago akismet.php 1 month ago changelog.txt 1 year ago class-akismet-abilities.php 1 month ago class-akismet-compatible-plugins.php 9 months ago class-akismet-connector.php 1 month ago class.akismet-admin.php 1 month ago class.akismet-cli.php 1 year ago class.akismet-rest-api.php 2 months ago class.akismet-widget.php 7 months ago class.akismet.php 1 month ago index.php 1 year ago readme.txt 1 month ago wrapper.php 1 year ago
class.akismet-widget.php
178 lines
1 <?php
2 /**
3 * @package Akismet
4 */
5
6 // We plan to gradually remove all of the disabled lint rules below.
7 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
8
9 /**
10 * Akismet Widget Class
11 */
12 class Akismet_Widget extends WP_Widget {
13
14 /**
15 * Constructor
16 */
17 function __construct() {
18 parent::__construct(
19 'akismet_widget',
20 __( 'Akismet Widget', 'akismet' ),
21 array( 'description' => __( 'Display the number of spam comments Akismet has caught', 'akismet' ) )
22 );
23 }
24
25 /**
26 * Outputs the widget settings form
27 *
28 * @param array $instance The widget options
29 */
30 public function form( $instance ) {
31 if ( $instance && isset( $instance['title'] ) ) {
32 $title = $instance['title'];
33 } else {
34 $title = __( 'Spam Blocked', 'akismet' );
35 }
36 ?>
37
38 <p>
39 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'akismet' ); ?></label>
40 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
41 </p>
42
43 <?php
44 }
45
46 /**
47 * Updates the widget settings
48 *
49 * @param array $new_instance New widget instance
50 * @param array $old_instance Old widget instance
51 * @return array Updated widget instance
52 */
53 public function update( $new_instance, $old_instance ) {
54 $instance = array();
55 $instance['title'] = sanitize_text_field( $new_instance['title'] );
56 return $instance;
57 }
58
59 /**
60 * Outputs the widget content
61 *
62 * @param array $args Widget arguments
63 * @param array $instance Widget instance
64 */
65 public function widget( $args, $instance ) {
66 $count = get_option( 'akismet_spam_count' );
67
68 if ( ! isset( $instance['title'] ) ) {
69 $instance['title'] = __( 'Spam Blocked', 'akismet' );
70 }
71
72 echo $args['before_widget'];
73 if ( ! empty( $instance['title'] ) ) {
74 echo $args['before_title'];
75 echo esc_html( $instance['title'] );
76 echo $args['after_title'];
77 }
78 ?>
79
80 <style>
81 .a-stats {
82 --akismet-color-mid-green: #357b49;
83 --akismet-color-white: #fff;
84 --akismet-color-light-grey: #f6f7f7;
85
86 max-width: 350px;
87 width: auto;
88 }
89
90 .a-stats * {
91 all: unset;
92 box-sizing: border-box;
93 }
94
95 .a-stats strong {
96 font-weight: 600;
97 }
98
99 .a-stats a.a-stats__link,
100 .a-stats a.a-stats__link:visited,
101 .a-stats a.a-stats__link:active {
102 background: var(--akismet-color-mid-green);
103 border: none;
104 box-shadow: none;
105 border-radius: 8px;
106 color: var(--akismet-color-white);
107 cursor: pointer;
108 display: block;
109 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
110 font-weight: 500;
111 padding: 12px;
112 text-align: center;
113 text-decoration: none;
114 transition: all 0.2s ease;
115 }
116
117 /* Extra specificity to deal with TwentyTwentyOne focus style */
118 .widget .a-stats a.a-stats__link:focus {
119 background: var(--akismet-color-mid-green);
120 color: var(--akismet-color-white);
121 text-decoration: none;
122 }
123
124 .a-stats a.a-stats__link:hover {
125 filter: brightness(110%);
126 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
127 }
128
129 .a-stats .count {
130 color: var(--akismet-color-white);
131 display: block;
132 font-size: 1.5em;
133 line-height: 1.4;
134 padding: 0 13px;
135 white-space: nowrap;
136 }
137 </style>
138
139 <div class="a-stats">
140 <a href="https://akismet.com?utm_source=akismet_plugin&amp;utm_campaign=plugin_static_link&amp;utm_medium=in_plugin&amp;utm_content=widget_stats" class="a-stats__link" target="_blank" rel="noopener" style="background-color: var(--akismet-color-mid-green); color: var(--akismet-color-white);">
141 <?php
142
143 echo wp_kses(
144 sprintf(
145 /* translators: The placeholder is the number of pieces of spam blocked by Akismet. */
146 _n(
147 '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
148 '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
149 $count,
150 'akismet'
151 ),
152 number_format_i18n( $count )
153 ),
154 array(
155 'strong' => array(
156 'class' => true,
157 ),
158 )
159 );
160
161 ?>
162 </a>
163 </div>
164
165 <?php
166 echo $args['after_widget'];
167 }
168 }
169
170 /**
171 * Register the Akismet widget
172 */
173 function akismet_register_widgets() {
174 register_widget( 'Akismet_Widget' );
175 }
176
177 add_action( 'widgets_init', 'akismet_register_widgets' );
178