Plugin Directory

Changeset 2999014


Ignore:
Timestamp:
11/20/2023 03:20:51 PM (2 years ago)
Author:
marcodedo
Message:

1.1.3 - 2023-11-20

  • Bug fixed (dashboard.php)
Location:
disclaimer-popup/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • disclaimer-popup/trunk/README.txt

    r2908891 r2999014  
    44Tags: disclaimer, popup, modal, alert, note, message, advice, caution
    55Requires at least: 4.5
    6 Tested up to: 6.2
     6Tested up to: 6.3
    77Stable tag: 1.0.1
    88Requires PHP: 5.4
     
    7676== Changelog ==
    7777
     78= 1.1.3 - 2023-11-20 =
     79* Bug fixed (dashboard.php)
     80
    7881= 1.1.2 - 2023-05-06 =
    7982* Added option for popup alignment
  • disclaimer-popup/trunk/assets/meta-box/inc/about/dashboard.php

    r2908846 r2999014  
    66    private $slug;
    77
    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'] );
    138
    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     }
    189
    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         <?php
    83     }
    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     }
    9010}
  • disclaimer-popup/trunk/wp-disclaimer-popup.php

    r2908892 r2999014  
    1010 *
    1111 * @link              http://www.themeinthebox.com
    12  * @since             1.1.2
     12 * @since             1.1.3
    1313 * @package           Wp_Disclaimer_Popup
    1414 *
     
    1717 * Plugin URI:        http://www.themeinthebox.com/wp-disclaimer-popup
    1818 * 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.2
     19 * Version:           1.1.3
    2020 * Author:            ThemeintheBox
    2121 * Author URI:        http://www.themeinthebox.com
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'WP_DISCLAIMER_POPUP_VERSION', '1.1.2' );
     38define( 'WP_DISCLAIMER_POPUP_VERSION', '1.1.3' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.