Changeset 2999014
- Timestamp:
- 11/20/2023 03:20:51 PM (2 years ago)
- Location:
- disclaimer-popup/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
assets/meta-box/inc/about/dashboard.php (modified) (1 diff)
-
wp-disclaimer-popup.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
disclaimer-popup/trunk/README.txt
r2908891 r2999014 4 4 Tags: disclaimer, popup, modal, alert, note, message, advice, caution 5 5 Requires at least: 4.5 6 Tested up to: 6. 26 Tested up to: 6.3 7 7 Stable tag: 1.0.1 8 8 Requires PHP: 5.4 … … 76 76 == Changelog == 77 77 78 = 1.1.3 - 2023-11-20 = 79 * Bug fixed (dashboard.php) 80 78 81 = 1.1.2 - 2023-05-06 = 79 82 * Added option for popup alignment -
disclaimer-popup/trunk/assets/meta-box/inc/about/dashboard.php
r2908846 r2999014 6 6 private $slug; 7 7 8 public function __construct( string $feed_url, string $link, array $translations ) {9 $this->feed_url = $feed_url;10 $this->link = $link;11 $this->translations = $translations;12 $this->slug = sanitize_title( $translations['title'] );13 8 14 $transient_name = $this->get_transient_name();15 add_filter( "transient_$transient_name", [ $this, 'add_news' ] );16 add_action( "wp_ajax_{$this->slug}-dismiss-news", [ $this, 'ajax_dismiss' ] );17 }18 9 19 private function get_transient_name() : string {20 $locale = get_user_locale();21 return 'dash_v2_' . md5( "dashboard_primary_{$locale}" );22 }23 24 public function add_news( string $value ) : string {25 $is_dismissed = get_user_meta( get_current_user_id(), $this->slug . '_dismiss_news', true );26 $is_dismissed = apply_filters( 'rwmb_dismiss_dashboard_widget', $is_dismissed );27 if ( $is_dismissed ) {28 return $value;29 }30 31 ob_start();32 $this->output_script();33 $script = ob_get_clean();34 35 return $value . $this->get_html() . $script;36 }37 38 private function get_html() : string {39 $cache_key = $this->slug . '-news';40 $output = get_transient( $cache_key );41 if ( false !== $output ) {42 return $output;43 }44 45 $feeds = [46 $this->slug => [47 'link' => $this->link,48 'url' => $this->feed_url,49 'title' => $this->translations['title'],50 'items' => 3,51 'show_summary' => 0,52 'show_author' => 0,53 'show_date' => 0,54 ],55 ];56 ob_start();57 wp_dashboard_primary_output( 'dashboard_primary', $feeds );58 $output = (string) ob_get_clean();59 60 $output = (string) preg_replace( '/<a(.+?)>(.+?)<\/a>/i', '<a$1>' . esc_html( $this->translations['title'] ) . ': $2</a>', $output );61 $output = str_replace( '<li>', '<li class="' . esc_attr( $this->slug ) . '-news-item"><a href="#" class="dashicons dashicons-no-alt" title="' . esc_attr( $this->translations['dismiss_tooltip'] ) . '" style="float: right; box-shadow: none; margin-left: 5px;"></a>', $output );62 63 set_transient( $cache_key, $output, DAY_IN_SECONDS );64 65 return $output;66 }67 68 private function output_script() {69 ?>70 <script>71 document.addEventListener( 'click', e => {72 if ( !e.target.classList.contains( 'dashicons' ) || !e.target.closest( '.<?php echo esc_js( $this->slug ) ?>-news-item' ) ) {73 return;74 }75 e.preventDefault();76 if ( confirm( "<?php echo esc_js( $this->translations['dismiss_confirm'] ) ?>" ) ) {77 fetch( `${ ajaxurl }?action=<?php echo esc_js( $this->slug ) ?>-dismiss-news&_ajax_nonce=<?php echo esc_js( wp_create_nonce( 'dismiss' ) ) ?>` )78 .then( () => document.querySelectorAll( '.<?php echo esc_js( $this->slug ) ?>-news-item' ).forEach( el => el.remove() ) );79 }80 } );81 </script>82 <?php83 }84 85 public function ajax_dismiss() {86 check_ajax_referer( 'dismiss' );87 update_user_meta( get_current_user_id(), $this->slug . '_dismiss_news', 1 );88 wp_send_json_success();89 }90 10 } -
disclaimer-popup/trunk/wp-disclaimer-popup.php
r2908892 r2999014 10 10 * 11 11 * @link http://www.themeinthebox.com 12 * @since 1.1. 212 * @since 1.1.3 13 13 * @package Wp_Disclaimer_Popup 14 14 * … … 17 17 * Plugin URI: http://www.themeinthebox.com/wp-disclaimer-popup 18 18 * Description: It helps to quickly create pop-ups with disclaimers that appear when the website is opened. You can control many graphic parts of the popup, and you can also decide how many days the cookie is valid, before being requested again for the popup. 19 * Version: 1.1. 219 * Version: 1.1.3 20 20 * Author: ThemeintheBox 21 21 * Author URI: http://www.themeinthebox.com … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'WP_DISCLAIMER_POPUP_VERSION', '1.1. 2' );38 define( 'WP_DISCLAIMER_POPUP_VERSION', '1.1.3' ); 39 39 40 40 /**
Note: See TracChangeset
for help on using the changeset viewer.