[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 class Akismet_Widget extends WP_Widget { 10 11 function __construct() { 12 load_plugin_textdomain( 'akismet' ); 13 14 parent::__construct( 15 'akismet_widget', 16 __( 'Akismet Widget', 'akismet' ), 17 array( 'description' => __( 'Display the number of spam comments Akismet has caught', 'akismet' ) ) 18 ); 19 20 if ( is_active_widget( false, false, $this->id_base ) ) { 21 add_action( 'wp_head', array( $this, 'css' ) ); 22 } 23 } 24 25 function css() { 26 ?> 27 28 <style type="text/css"> 29 .a-stats { 30 width: auto; 31 } 32 .a-stats a { 33 background: #7CA821; 34 background-image:-moz-linear-gradient(0% 100% 90deg,#5F8E14,#7CA821); 35 background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#7CA821),to(#5F8E14)); 36 border: 1px solid #5F8E14; 37 border-radius:3px; 38 color: #CFEA93; 39 cursor: pointer; 40 display: block; 41 font-weight: normal; 42 height: 100%; 43 -moz-border-radius:3px; 44 padding: 7px 0 8px; 45 text-align: center; 46 text-decoration: none; 47 -webkit-border-radius:3px; 48 width: 100%; 49 } 50 .a-stats a:hover { 51 text-decoration: none; 52 background-image:-moz-linear-gradient(0% 100% 90deg,#6F9C1B,#659417); 53 background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#659417),to(#6F9C1B)); 54 } 55 .a-stats .count { 56 color: #FFF; 57 display: block; 58 font-size: 15px; 59 line-height: 16px; 60 padding: 0 13px; 61 white-space: nowrap; 62 } 63 </style> 64 65 <?php 66 } 67 68 function form( $instance ) { 69 if ( $instance && isset( $instance['title'] ) ) { 70 $title = $instance['title']; 71 } else { 72 $title = __( 'Spam Blocked', 'akismet' ); 73 } 74 ?> 75 76 <p> 77 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'akismet' ); ?></label> 78 <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 ); ?>" /> 79 </p> 80 81 <?php 82 } 83 84 function update( $new_instance, $old_instance ) { 85 $instance = array(); 86 $instance['title'] = strip_tags( $new_instance['title'] ); 87 return $instance; 88 } 89 90 function widget( $args, $instance ) { 91 $count = get_option( 'akismet_spam_count' ); 92 93 if ( ! isset( $instance['title'] ) ) { 94 $instance['title'] = __( 'Spam Blocked', 'akismet' ); 95 } 96 97 echo $args['before_widget']; 98 if ( ! empty( $instance['title'] ) ) { 99 echo $args['before_title']; 100 echo esc_html( $instance['title'] ); 101 echo $args['after_title']; 102 } 103 ?> 104 105 <div class="a-stats"> 106 <a href="https://akismet.com" target="_blank" rel="noopener" title=""> 107 <?php 108 109 echo wp_kses( 110 sprintf( 111 /* translators: The placeholder is the number of pieces of spam blocked by Akismet. */ 112 _n( 113 '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', 114 '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', 115 $count, 116 'akismet' 117 ), 118 number_format_i18n( $count ) 119 ), 120 array( 121 'strong' => array( 122 'class' => true, 123 ), 124 ) 125 ); 126 127 ?> 128 </a> 129 </div> 130 131 <?php 132 echo $args['after_widget']; 133 } 134 } 135 136 function akismet_register_widgets() { 137 register_widget( 'Akismet_Widget' ); 138 } 139 140 add_action( 'widgets_init', 'akismet_register_widgets' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |