Changeset 2497410
- Timestamp:
- 03/16/2021 10:41:20 PM (5 years ago)
- Location:
- wp-dobby/trunk
- Files:
-
- 2 edited
-
dobby.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-dobby/trunk/dobby.php
r1733044 r2497410 1 <?php # -*- coding: utf-8 -*- 2 3 /* 4 * Plugin Name: Dobby 5 * Plugin URI: https://wordpress.org/plugins/wp-dobby/ 6 * Description: Dobby, the friendly Admin Elf, takes care of all your (unwanted) admin notices. 7 * Author: Thorsten Frommen 8 * Author URI: https://tfrommen.de 9 * Version: 1.3.0 10 * Text Domain: wp-dobby 11 * License: MIT 1 <?php 2 /** 3 * Dobby 4 * 5 * @package tfrommen\Dobby 6 * @author Thorsten Frommen 7 * @license MIT 8 * 9 * @wordpress-plugin 10 * Plugin Name: Dobby 11 * Plugin URI: https://wordpress.org/plugins/wp-dobby/ 12 * Description: Dobby, the friendly Admin Elf, takes care of all your (unwanted) admin notices. 13 * Version: 1.4.0 14 * Requires at least: 3.1 15 * Requires PHP: 5.4 16 * Author: Thorsten Frommen 17 * Author URI: https://tfrommen.de 18 * License: MIT 19 * Text Domain: wp-dobby 12 20 */ 13 21 … … 30 38 31 39 /** 32 * Bootstrap sthe plugin.40 * Bootstrap the plugin. 33 41 * 34 42 * @since 1.0.0 … … 46 54 $action = 'admin_notices'; 47 55 } 48 add_action( $action, function () {49 56 50 ob_start(); 51 }, (int) ( PHP_INT_MAX + 1 ) ); 57 add_action( 58 $action, 59 function () { 52 60 53 add_action( 'all_admin_notices', function () { 61 ob_start(); 62 }, 63 (int) ( PHP_INT_MAX + 1 ) 64 ); 54 65 55 $contents = trim( ob_get_clean() ); 56 if ( '' === $contents ) { 57 return; 58 } 66 add_action( 67 'all_admin_notices', 68 function () { 59 69 60 load_plugin_textdomain( 'wp-dobby' ); 70 $contents = trim( ob_get_clean() ); 71 if ( '' === $contents ) { 72 return; 73 } 61 74 62 $dobby_id = 'dobby';75 load_plugin_textdomain( 'wp-dobby' ); 63 76 64 $closet_id = 'dobby-closet'; 65 ?> 66 <div id="<?php echo esc_attr( $dobby_id ); ?>" class="notice hide-if-js"> 67 <p> 68 <span>✨</span> 69 <?php esc_html_e( 'Dobby took care of your admin notices.', 'wp-dobby' ); ?> 70 <button class="button"><?php esc_html_e( 'Reveal', 'wp-dobby' ); ?></button> 71 </p> 72 </div> 73 <div id="<?php echo esc_attr( $closet_id ); ?>" class="hide-if-js"> 77 $dobby_id = 'dobby'; 78 79 $closet_id = 'dobby-closet'; 80 ?> 81 <div id="<?php echo esc_attr( $dobby_id ); ?>" class="notice hide-if-js"> 82 <p> 83 <span>✨</span> 84 <?php esc_html_e( 'Dobby took care of your admin notices.', 'wp-dobby' ); ?> 85 <button class="button"><?php esc_html_e( 'Reveal', 'wp-dobby' ); ?></button> 86 </p> 87 </div> 88 <div id="<?php echo esc_attr( $closet_id ); ?>" class="hide-if-js"> 89 <?php 90 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 91 echo $contents; 92 ?> 93 </div> 74 94 <?php 75 // @codingStandardsIgnoreLine 76 echo $contents; 77 ?> 78 </div> 79 <?php 80 wp_enqueue_script( 81 'dobby', 82 plugin_dir_url( __FILE__ ) . 'assets/js/dobby.js', 83 [ 'jquery' ], 84 filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/dobby.js' ) 85 ); 95 wp_enqueue_script( 96 'dobby', 97 plugin_dir_url( __FILE__ ) . 'assets/js/dobby.js', 98 [ 'jquery' ], 99 filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/dobby.js' ), 100 [ 'in_footer' => true ] 101 ); 86 102 87 /** 88 * Filters the minimum number of admin notices required for Dobby to take action. 89 * 90 * @since 1.1.0 91 * 92 * @param int $threshold Required minimum number of admin notices. 93 */ 94 $threshold = (int) apply_filters( FILTER_THRESHOLD, 1 ); 95 wp_localize_script( 'dobby', 'dobbySettings', [ 96 'selectorCloset' => "#{$closet_id}", 97 'selectorDobby' => "#{$dobby_id}", 98 'threshold' => max( 1, $threshold ), 99 ] ); 100 }, PHP_INT_MAX ); 103 /** 104 * Filter the minimum number of admin notices required for Dobby to take action. 105 * 106 * @since 1.1.0 107 * 108 * @param int $threshold Required minimum number of admin notices. 109 */ 110 $threshold = (int) apply_filters( FILTER_THRESHOLD, 1 ); 111 wp_localize_script( 112 'dobby', 113 'dobbySettings', 114 [ 115 'selectorCloset' => "#{$closet_id}", 116 'selectorDobby' => "#{$dobby_id}", 117 'threshold' => max( 1, $threshold ), 118 ] 119 ); 120 }, 121 PHP_INT_MAX 122 ); 101 123 } 102 124 -
wp-dobby/trunk/readme.txt
r1733044 r2497410 3 3 Tags: admin, notices 4 4 Requires at least: 3.1.0 5 Tested up to: 4.86 Stable tag: v1.3.05 Tested up to: 5.7 6 Stable tag: 1.4.0 7 7 Requires PHP: 5.4 8 8 … … 30 30 31 31 == Changelog == 32 33 = 1.4.0 = 34 * Bump "Tested up to" header, see [issue #12](https://github.com/tfrommen/Dobby/issues/12). 32 35 33 36 = 1.3.0 =
Note: See TracChangeset
for help on using the changeset viewer.