~canonical-sysadmins/wordpress/4.7.4

« back to all changes in this revision

Viewing changes to wp-content/plugins/akismet/class.akismet-widget.php

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

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