Plugin Directory

Changeset 3232287


Ignore:
Timestamp:
01/30/2025 08:33:57 PM (11 months ago)
Author:
lschuyler
Message:

Akismet: enqueue widget inline styles

Location:
akismet/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • akismet/trunk/akismet.php

    r3227756 r3232287  
    77Plugin URI: https://akismet.com/
    88Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. Akismet Anti-spam keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
    9 Version: 5.3.6a5
     9Version: 5.3.6a6
    1010Requires at least: 5.8
    1111Requires PHP: 5.6.20
     
    4040}
    4141
    42 define( 'AKISMET_VERSION', '5.3.6a5' );
     42define( 'AKISMET_VERSION', '5.3.6a6' );
    4343define( 'AKISMET__MINIMUM_WP_VERSION', '5.8' );
    4444define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • akismet/trunk/class.akismet-widget.php

    r3223918 r3232287  
    1212        load_plugin_textdomain( 'akismet' );
    1313
     14        add_action( 'wp_enqueue_scripts', array( $this, 'akismet_widget_enqueue_styles' ) );
     15
    1416        parent::__construct(
    1517            'akismet_widget',
     
    1719            array( 'description' => __( 'Display the number of spam comments Akismet has caught', 'akismet' ) )
    1820        );
    19 
    20         if ( is_active_widget( false, false, $this->id_base ) ) {
    21             add_action( 'wp_head', array( $this, 'css' ) );
    22         }
    2321    }
    2422
    25     function css() {
    26         ?>
     23    public function akismet_widget_enqueue_styles() {
     24        // Register the stylesheet handle
     25        wp_register_style( 'akismet-widget-style', false ); // No external file, just a handle
    2726
    28 <style>
    29 .a-stats {
    30     --akismet-color-mid-green: #357b49;
    31     --akismet-color-white: #fff;
    32     --akismet-color-light-grey: #f6f7f7;
     27        // Enqueue the registered stylesheet
     28        wp_enqueue_style( 'akismet-widget-style' );
    3329
    34     max-width: 350px;
    35     width: auto;
    36 }
     30        // Add inline styles
     31        $inline_css = "
     32            .a-stats {
     33                --akismet-color-mid-green: #357b49;
     34                --akismet-color-white: #fff;
     35                --akismet-color-light-grey: #f6f7f7;
    3736
    38 .a-stats * {
    39     all: unset;
    40     box-sizing: border-box;
    41 }
     37                max-width: 350px;
     38                width: auto;
     39            }
    4240
    43 .a-stats strong {
    44     font-weight: 600;
    45 }
     41            .a-stats * {
     42                all: unset;
     43                box-sizing: border-box;
     44            }
    4645
    47 .a-stats a.a-stats__link,
    48 .a-stats a.a-stats__link:visited,
    49 .a-stats a.a-stats__link:active {
    50     background: var(--akismet-color-mid-green);
    51     border: none;
    52     border-radius: 8px;
    53     color: var(--akismet-color-white);
    54     cursor: pointer;
    55     display: block;
    56     font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
    57     font-weight: 500;
    58     padding: 12px;
    59     text-align: center;
    60     text-decoration: none;
    61     transition: all 0.2s ease;
    62 }
     46            .a-stats strong {
     47                font-weight: 600;
     48            }
    6349
    64 /* Extra specificity to deal with TwentyTwentyOne focus style */
    65 .widget .a-stats a.a-stats__link:focus {
    66     background: var(--akismet-color-mid-green);
    67     color: var(--akismet-color-white);
    68     text-decoration: none;
    69 }
     50            .a-stats a.a-stats__link,
     51            .a-stats a.a-stats__link:visited,
     52            .a-stats a.a-stats__link:active {
     53                background: var(--akismet-color-mid-green);
     54                border: none;
     55                box-shadow: none;
     56                border-radius: 8px;
     57                color: var(--akismet-color-white);
     58                cursor: pointer;
     59                display: block;
     60                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
     61                font-weight: 500;
     62                padding: 12px;
     63                text-align: center;
     64                text-decoration: none;
     65                transition: all 0.2s ease;
     66            }
    7067
    71 .a-stats a.a-stats__link:hover {
    72     filter: brightness(110%);
    73     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
    74 }
     68            /* Extra specificity to deal with TwentyTwentyOne focus style */
     69            .widget .a-stats a.a-stats__link:focus {
     70                background: var(--akismet-color-mid-green);
     71                color: var(--akismet-color-white);
     72                text-decoration: none;
     73            }
    7574
    76 .a-stats .count {
    77     color: var(--akismet-color-white);
    78     display: block;
    79     font-size: 1.5em;
    80     line-height: 1.4;
    81     padding: 0 13px;
    82     white-space: nowrap;
    83 }
    84 </style>
     75            .a-stats a.a-stats__link:hover {
     76                filter: brightness(110%);
     77                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
     78            }
    8579
    86         <?php
     80            .a-stats .count {
     81                color: var(--akismet-color-white);
     82                display: block;
     83                font-size: 1.5em;
     84                line-height: 1.4;
     85                padding: 0 13px;
     86                white-space: nowrap;
     87            }
     88        ";
     89        wp_add_inline_style( 'akismet-widget-style', $inline_css );
    8790    }
    8891
     
    124127        ?>
    125128
    126     <div class="a-stats">
    127         <?php // Specifying colors inline for maximum specificity without using !important ?>
    128         <a href="https://akismet.com" class="a-stats__link" target="_blank" rel="noopener" style="background-color: var(--akismet-color-mid-green); color: var(--akismet-color-white);">
    129             <?php
     129        <div class="a-stats">
     130            <?php // Specifying colors inline for maximum specificity without using !important ?>
     131            <a href="https://akismet.com" class="a-stats__link" target="_blank" rel="noopener" style="background-color: var(--akismet-color-mid-green); color: var(--akismet-color-white);">
     132                <?php
    130133
    131             echo wp_kses(
    132                 sprintf(
     134                echo wp_kses(
     135                    sprintf(
    133136                    /* translators: The placeholder is the number of pieces of spam blocked by Akismet. */
    134                     _n(
    135                         '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
    136                         '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
    137                         $count,
    138                         'akismet'
     137                        _n(
     138                            '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
     139                            '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
     140                            $count,
     141                            'akismet'
     142                        ),
     143                        number_format_i18n( $count )
    139144                    ),
    140                     number_format_i18n( $count )
    141                 ),
    142                 array(
    143                     'strong' => array(
    144                         'class' => true,
    145                     ),
    146                 )
    147             );
     145                    array(
     146                        'strong' => array(
     147                            'class' => true,
     148                        ),
     149                    )
     150                );
    148151
    149             ?>
    150         </a>
    151     </div>
     152                ?>
     153            </a>
     154        </div>
    152155
    153156        <?php
Note: See TracChangeset for help on using the changeset viewer.