Plugin Directory

Changeset 2021763


Ignore:
Timestamp:
01/30/2019 08:58:35 AM (7 years ago)
Author:
designwall
Message:

Release new version

Location:
dw-notifications
Files:
50 added
11 edited

Legend:

Unmodified
Added
Removed
  • dw-notifications/trunk/assets/css/dw-notifications.css

    r2012557 r2021763  
    142142  border-right: 0;
    143143  position: relative;
    144   padding-right: 15px;
    145144  width: 100%;
    146145  word-wrap: break-word;
     
    168167  font-size: 13px;
    169168  font-weight: 400;
    170   padding: 20px 0 20px 70px;
     169  padding: 20px 15px 20px 70px;
    171170  width: 100%;
    172171  word-wrap: break-word;
     
    230229  content: "\f058";
    231230  color: #84c31e;
     231}
     232.dw-notifications .list-notification li.dw-notif-show-older-wrap {
     233  text-align: center;
     234}
     235.dw-notifications .list-notification li.dw-notif-show-older-wrap a {
     236  padding: 20px 20px 20px 20px;
    232237}
    233238.notif-count-unchecked {
     
    327332  -moz-transform: rotate(45deg);
    328333}
     334
     335/**
     336---- List All ----*/
     337.dw-notifications-list-all {
     338  width: 100%;
     339}
     340.dw-notifications-list-all .notification-group {
     341  width: 100%;
     342  position: static;
     343  opacity: 1;
     344  visibility: visible;
     345  z-index: auto;
     346}
     347
     348.dw-notifications-list-all .notification-group ul.list-notification {
     349  max-height: unset;
     350}
     351
    329352/**
    330353---- Use php shortcode ----*/
  • dw-notifications/trunk/assets/js/dw-notifications.js

    r2012557 r2021763  
    33    var time = dwnotif.dwnotif_current_time;
    44    var old_time = time;
    5 
    6     if(!$('#dw-notifications').length){
    7         return;
    8     }
     5    var document_title = document.title;
     6    var count_unchecked = 0;
     7
    98
    109    var change_numer = 0;
     
    1716        minTimeRequest = dwnotif.dwnotif_min_time_request * 1000;
    1817    }
     18
     19    if($('#dw-notifications').length){
     20        setCountUnchecked(count_unchecked);
     21        autoCheck();
     22    }
    1923   
    20 
    21     autoCheck();
     24   
    2225
    2326    function changeTimeRequest(changed = false){
     
    4952        changeTimeItem(time);
    5053        changeReadItem();
     54        changeCountTitle();
    5155        setTimeout(checkNotifications, currentTimeRequest);
     56    }
     57
     58    function setCountUnchecked(count){
     59        setCookie('dw_count_user_unchecked', count, 3600);
     60    }
     61
     62    function changeCountTitle() {
     63        var count = parseInt(getCookie('dw_count_user_unchecked'));
     64        var newTitle = document_title;
     65        if(count){
     66            var newTitle = '(' + count + ') ' + document_title;
     67        }
     68        document.title = newTitle;
    5269    }
    5370
     
    7289                            $('#dw-notifications').find('.dw-notification-btn').addClass('has-notification');
    7390                            $('#dw-notifications').find('.notif-count-unchecked').text(data.result.count_unchecked);
     91                            setCountUnchecked(data.result.count_unchecked);
    7492                        }
    7593
     
    8199                    }
    82100
    83                     /*if(data.result.length>0){
    84                         for(var i=0;i<data.result.length;i++){
    85                             $('.dw-notifications._' + data.result[i].id).find('.list-notification').html(data.result[i].html);
    86                             if(data.result[i].new){
    87                                 addPopup(data.result[i].id, data.result[i].new);
    88                                 changed = true;
    89                             }
    90                             if(data.result[i].count_unchecked){
    91                                 addHasNotifications(data.result[i].id, data.result[i].count_unchecked);
    92                             }
    93                         }
    94                     }*/
    95101                    time = data.time;
    96102                }
     
    163169       
    164170        $(this).removeClass('has-notification');
     171        setCountUnchecked(0);
     172        changeCountTitle();
    165173
    166174        var notifications = $(this).closest('.dw-notifications');
     
    198206    });
    199207
     208    //show older
     209
     210    $('.dw-notif-show-older').on('click', function(event){
     211        event.preventDefault();
     212        var older_button = $(this);
     213        var older_wrap = $(this).closest('.dw-notif-show-older-wrap');
     214        var data_time = parseInt($(this).attr('data-time'));
     215        var data_page = parseInt($(this).attr('data-page'));
     216        $.ajax({
     217            url: dwnotif.dwnotif_ajax_url,
     218            type: 'POST',
     219            dataType: 'json',
     220            data: {
     221                action: 'dwnotif_get_older_notifications',
     222                nonce: dwnotif.dwnotif_nonce,
     223                time: data_time,
     224                page: data_page,
     225            },
     226            success: function( data ) {
     227                if (data.success) {
     228                    if(data.result.older_notifications){
     229                        older_wrap.before(data.result.older_notifications);
     230                        data_page++;
     231                        older_button.attr('data-page', data_page);
     232                    }else{
     233                        older_wrap.text(dwnotif.dwnotif_text.older_not_found);
     234                    }
     235                }
     236                return false;
     237            },
     238            error: function (request, status, error) {
     239               
     240            }
     241        });
     242    });
     243
    200244    //mark item read
    201245    $(document).on('click', '.list-notification .unread', function (e) {
     
    234278    $(document).on('click', '.dw-notifications', function (e) {
    235279      e.stopPropagation();
     280    });
     281
     282    $('#dw-notifications .noti-body').bind('mousewheel DOMMouseScroll', function(e) {
     283        var scrollTo = null;
     284
     285        if (e.type == 'mousewheel') {
     286            scrollTo = (e.originalEvent.wheelDelta * -1);
     287        }
     288        else if (e.type == 'DOMMouseScroll') {
     289            scrollTo = 40 * e.originalEvent.detail;
     290        }
     291
     292        if (scrollTo) {
     293            e.preventDefault();
     294            $(this).scrollTop(scrollTo + $(this).scrollTop());
     295        }
    236296    });
    237297});
  • dw-notifications/trunk/dw-notifications.php

    r2012557 r2021763  
    55 *  Author: DesignWall
    66 *  Author URI: http://www.designwall.com
    7  *  Version: 1.0.2
     7 *  Version: 1.0.3
    88 *  Text Domain: dw-notifications
    99 */
     
    1616class DW_Notifications{
    1717    public function __construct() {
    18         $this->version = '1.0.2';
     18        $this->version = '1.0.3';
    1919        $this->define_constants();
    2020        $this->includes();
  • dw-notifications/trunk/inc/Ajax.php

    r2012557 r2021763  
    1010        add_action( 'wp_ajax_nopriv_dwnotif_check_notifications', array($this, 'check_notifications') );
    1111
     12        add_action( 'wp_ajax_dwnotif_get_older_notifications', array($this, 'get_older_notifications') );
     13        add_action( 'wp_ajax_nopriv_dwnotif_get_older_notifications', array($this, 'get_older_notifications') );
     14
    1215        add_action( 'wp_ajax_dwnotif_mark_all_as_read', array($this, 'mark_all_as_read') );
    1316        add_action( 'wp_ajax_dwnotif_mark_user_checked', array($this, 'mark_user_checked') );
     17    }
     18
     19    public function get_older_notifications(){
     20        check_ajax_referer( 'dwnotif_nonce', 'nonce' );
     21        $result = array();
     22        $time = $_POST['time']?$_POST['time']:current_time('timestamp');
     23        $page = $_POST['page']?$_POST['page']:2;
     24
     25        $notification = new DWNOTIF_Notification();
     26
     27        $args = array(
     28            'paged' => $page,
     29            'date_query' => array(
     30                array(
     31                    'before' => array(
     32                        'year'  => date("Y", $time),
     33                        'month' => date("m", $time),
     34                        'day'   => date("d", $time),
     35                        'hour'   => date("H", $time),
     36                        'minute'   => date("i", $time),
     37                        'second'   => date("s", $time),
     38                    ),
     39                    'column ' => 'post_date',
     40                    'inclusive' => false
     41                )
     42            ),
     43        );
     44       
     45        $older_notifications = $notification->get_notifications($args);
     46
     47        if($older_notifications){
     48            $result['older_notifications'] = $notification->get_item_template($older_notifications);
     49        }else{
     50            $result['older_notifications'] = false;
     51        }
     52
     53        echo json_encode(array('success'=>true, 'result'=>$result));
     54        die();
     55
    1456    }
    1557
  • dw-notifications/trunk/inc/Notification.php

    r2012557 r2021763  
    223223            'post_title' => $notification['title'],
    224224            'post_content' => $notification['content'],
    225             'post_status' => 'publish'
     225            'post_parent' => $notification['parent'],
     226            'post_status' => 'publish',
    226227        );
    227228
     
    255256            'image' => dwnotif_default_image(),
    256257            'auto' => true, // add this to check auto genrate
     258            'parent' => 0, // if source is post_type
    257259        ));
    258260    }
     
    348350        extract($data);
    349351
     352        $current_time = current_time('timestamp');
    350353        $notifications = $this->get_notifications($data);
    351354        $count_unchecked = $this->count_user_unchecked();
     
    360363    }
    361364
     365    public function get_list_all_template($data = array()){
     366
     367        $default_data = array(
     368            'id' => $this->id,
     369            'paged' => 1,
     370        );
     371        $data = (array)$data;
     372        $data = wp_parse_args( $data, $default_data);
     373        $data = apply_filters('dwnotif_list_all_data', $data);
     374        extract($data);
     375
     376        $current_time = current_time('timestamp');
     377        $notifications = $this->get_notifications($data);
     378
     379        $file_dir = dwnotif_load_template('notification-list-all', false);
     380
     381        //get list item
     382        ob_start();
     383        include($file_dir);
     384        $html = ob_get_contents();
     385        ob_end_clean();
     386
     387        return $html;
     388    }
    362389   
    363390    public function get_list_template($data = array()){
     
    445472
    446473        $user_checked_time = get_user_meta($user_id, 'dwnotif_user_checked', true);
     474        if(!$user_checked_time){
     475            $user_checked_time = current_time('timestamp');
     476        }
    447477
    448478        $dw_notification_to = array('all');
     
    479509        $notifications = get_posts($args);
    480510
    481         return $notifications?count($notifications):0;
     511        $count =  $notifications?count($notifications):0;
     512
     513        return $count;
    482514    }
    483515
  • dw-notifications/trunk/inc/Script.php

    r2012557 r2021763  
    1212
    1313    function enqueue_style() {
    14         global $dw_notif_options;
     14        global $dw_notif_options, $dwnotif;
    1515
    1616        $min_time_request = isset( $dw_notif_options['min-time-request'] ) ?  $dw_notif_options['min-time-request'] : 0;
     
    2929                'YEAR_IN_SECONDS' => YEAR_IN_SECONDS,
    3030            ),
     31            'dwnotif_text' => array(
     32                'older_not_found' => __('That\'s all', 'dw-notifications')
     33            ),
    3134           
    3235            'dwnotif_min_time_request' => $min_time_request
     
    3437
    3538        wp_enqueue_style( 'dwnotif-fontawesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
    36         wp_enqueue_style( 'dwnotif-default-style', DWNOTIF_URI . 'assets/css/dw-notifications.css');
    37         wp_enqueue_script( 'dwnotif-default', DWNOTIF_URI . 'assets/js/dw-notifications.js', array( 'jquery'));
     39        wp_enqueue_style( 'dwnotif-default-style', DWNOTIF_URI . 'assets/css/dw-notifications.css', array(), $dwnotif->version);
     40        wp_enqueue_script( 'dwnotif-default', DWNOTIF_URI . 'assets/js/dw-notifications.js', array( 'jquery'), $dwnotif->version);
    3841        wp_localize_script( 'dwnotif-default', 'dwnotif', $dw_notifications_script_vars );
    3942    }
  • dw-notifications/trunk/inc/Shortcode.php

    r2012557 r2021763  
    1313
    1414        add_shortcode( 'dw_notif', array( $this, 'show_notifications') );
     15        add_shortcode( 'dw_notif_list_all', array( $this, 'show_list_all_notifications') );
    1516
    1617        //add filter to use shortcode in wp menu setup
     
    6465    }
    6566
     67    public function show_list_all_notifications( $atts ){
     68        global $dwnotif;
     69        $notification = $dwnotif->notification;
     70
     71        $html = $notification->get_list_all_template();
     72        $html = $this->sanitize_output( $html );
     73        return apply_filters( 'dwnotif_shortcode_list_all', $html );
     74    }
     75
    6676}
    6777
  • dw-notifications/trunk/inc/integrations/wordpress-post/loader.php

    r2012557 r2021763  
    1717                $image = dwnotif_default_image();
    1818                if(has_post_thumbnail($post_ID)){
    19                     $image = get_the_post_thumbnail($post_ID, 'post-thumbnail') ;
     19                    $image = get_the_post_thumbnail_url($post_ID, 'post-thumbnail') ;
    2020                }
    2121
    22                 $notif = array('title'=>$title, 'link' => $link, 'image' => $image);
    23                 dwnotif_add_notification('all', $notif);
     22                $notif = array('title'=>$title, 'link' => $link, 'image' => $image, 'parent'=>$post_ID);
     23                $notif = apply_filters('dwnotif_insert_wp_post_data', $notif, $post_ID, $post);
     24
     25                $to = apply_filters('dwnotif_insert_wp_post_to', 'all', $post_ID, $post);
     26                dwnotif_add_notification( $to, $notif );
    2427            }
    2528           
  • dw-notifications/trunk/readme.txt

    r2012558 r2021763  
    44Requires at least: 3.0.1
    55Tested up to: 5.0.3
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.3
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    3232* Select css type.
    3333* Add Shortcode in Menu
     34* Load more.
     35* All notification shortcode
    3436
    35 = Upcoming features =
    36 * Load more.
    37 * All notification page
     37ShortCode
     38[dw_notif], [dw_notif_list_all]
    3839
    3940
     
    4142You can find [Documents](https://www.designwall.com/guide/dw-notifications/) and more detailed information about DW GDPR plugin on [DesignWall.com](http://www.designwall.com/).
    4243We provide support both on support forum on WordPress.org and our [support page](http://www.designwall.com/question/) on DesignWall.
    43 
    44 = Source =
    45 [Free for commercial use](https://www.iconfinder.com/icons/728992/configuration_control_dashboard_setting_speed_system_tool_icon#size=128)
    4644
    4745= Languages supported: =
     
    6058== Changelog ==
    6159
     60= 1.0.3 =
     61
     62* Add load more/show older button
     63* Add shortcode [dw_notif_list_all]
     64* Add notification counter on the tab page title
     65
    6266= 1.0.2 =
    6367
  • dw-notifications/trunk/templates/default/notification-alert.php

    r2012557 r2021763  
    1616        <ul class="list-notification noti-body">
    1717            <?php include dwnotif_load_template( 'notification-list', false );?>
     18            <li class="dw-notif-show-older-wrap"><a href="#" class="dw-notif-show-older" data-time="<?php echo $current_time;?>" data-page="2"><?php _e( 'Show older', 'dw-notifications' );?></a></li>
    1819        </ul>
     20        <div class="clearfix noti-headerbotom">
     21           
     22        </div>
    1923    </div>
    2024   
  • dw-notifications/trunk/templates/default/notification-item.php

    r2012557 r2021763  
    1919        </div>
    2020        <div><?php echo $notification->post_title; ?></div>
    21         <date class="notif-time"><?php echo human_time_diff( $notification_time, current_time('timestamp') ) . __( ' ago', 'dw-notifications' ); ?></date>
     21        <date class="notif-time"><?php echo human_time_diff( $notification_time, current_time('timestamp') ); ?></date>
    2222    </a>
    2323</li>
Note: See TracChangeset for help on using the changeset viewer.