Plugin Directory

Changeset 2994668


Ignore:
Timestamp:
11/12/2023 11:15:04 AM (2 years ago)
Author:
roumi
Message:

Release 3.0.0

Location:
wp-admin-notification-center
Files:
24 added
8 edited
10 copied

Legend:

Unmodified
Added
Removed
  • wp-admin-notification-center/tags/3.0.0/assets/js/notice.js

    r2900860 r2994668  
    33    preAdminNotifications: '',
    44    adminNotifications: [],
     5    notificationsDisplayed: [],
    56    buttonNotification: '',
    67    closeButton: '',
     
    4243        setTimeout(() => {
    4344            this.moveNotifications();
     45            this.saveNotices();
    4446        }, 500);
    4547    },
    4648    initNotificationCenterStyle: function () {
    4749        //We get the top and left to place it
    48         let top = this.buttonNotification.offsetTop + this.buttonNotification.offsetHeight;
     50        const top = this.buttonNotification.offsetTop + this.buttonNotification.offsetHeight;
    4951
    50         let paddingTopContainer = document.defaultView.getComputedStyle(this.wancContainer, '').getPropertyValue('padding-top').replace(/[^-\d\.]/g, '');
     52        const paddingTopContainer = document.defaultView.getComputedStyle(this.wancContainer, '').getPropertyValue('padding-top').replace(/[^-\d\.]/g, '');
    5153
    5254        //We place it
     
    8284            //We display it if this is a not a crucial notification
    8385            this.wancContainer.appendChild(this.adminNotifications[i]);
     86            this.notificationsDisplayed.push(this.adminNotifications[i]);
    8487
    8588            if (this.wancContainer.lastChild.offsetHeight > 0) numberOfNotification++;
     
    111114    },
    112115    needToBeDisplayed: function (notification) {
    113         //let's run the settings and check if there something to display
     116        //let's run the settings and check if there is something to display
    114117        for (let [noticeClass, displayNotice] of Object.entries(this.notificationSettings)) {
    115118            if (displayNotice !== 1 && notification.classList.contains(noticeClass)) return true;
     
    130133
    131134        // we set a nice array by removing all white space at the start and the end of each word
    132         let formattedWords = [];
     135        const formattedWords = [];
    133136        this[option].map(word => {
    134137            formattedWords.push(word.trim());
     
    151154            if (notWhiteListed) this.adminNotifications.push(this.preAdminNotifications[i]);
    152155        }
     156    },
     157    saveNotices: function () {
     158        const formData = new FormData();
     159
     160        formData.set('action', 'save_notices');
     161        this.notificationsDisplayed.forEach((notice, index) => {
     162            formData.set(`notices[${index}]`, JSON.stringify(notice.outerHTML));
     163        });
     164
     165        fetch(ajaxurl, {method: 'POST', body: formData}).then(response => {
     166            return response.text();
     167        });
    153168    }
    154169};
  • wp-admin-notification-center/tags/3.0.0/assets/js/notice_not_allowed.js

    r2375266 r2994668  
    11const wanc_notification_not_allowed = {
    22    init: function () {
    3         let adminNotifications = document.querySelectorAll('.notice, #message');
     3        const adminNotifications = document.querySelectorAll('.notice, #message');
    44        for (let i = 0 ; i < adminNotifications.length ; i++) {
    55            adminNotifications[i].remove();
  • wp-admin-notification-center/tags/3.0.0/index.php

    r2966106 r2994668  
    66Author URI: https://github.com/roumilb
    77License: GPLv3
    8 Version: 2.3.3
     8Version: 3.0.0
    99Text Domain: wanc
    1010Domain Path: /languages
  • wp-admin-notification-center/tags/3.0.0/lib/Debug.php

    r2771298 r2994668  
    11<?php
    22
    3 
    4 namespace WANC\lib;
    5 
     3namespace WANC;
    64
    75class Debug
  • wp-admin-notification-center/tags/3.0.0/readme.txt

    r2966106 r2994668  
    33Tags: notification, notice, notices, notifications, admin
    44Requires at least: 5.0
    5 Tested up to: 6.2
     5Tested up to: 6.4
    66Requires PHP: 7.0
    7 Stable tag: 2.3.3
     7Stable tag: 3.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3535== Changelog ==
    3636
    37 = 2.3.3 =
    38 * Fix CSRF Vulnerability
     37= 3.0.0 =
     38* Store notice displayed in the admin
     39* Listing of all notices stored
     40* Change admin menu icon
  • wp-admin-notification-center/tags/3.0.0/src/Init.php

    r2900859 r2994668  
    44namespace WANC;
    55
    6 use \WANC\Controllers\Settings;
    7 use \WANC\Controllers\NotificationCenter;
    8 use WANC\Services\SurveyService;
     6use WANC\Controllers\Notices;
     7use WANC\Controllers\Settings;
     8use WANC\Controllers\NotificationCenter;
     9use WANC\Services\UpdateService;
    910
    1011class Init
     
    1415    public function __construct()
    1516    {
     17        if (is_admin()) {
     18            (new UpdateService())->update();
     19        }
     20
    1621        add_action('admin_menu', [$this, 'registerWancOptionsPage']);
     22        add_action('admin_enqueue_scripts', [$this, 'addScript']);
     23        new Notices();
    1724        new Settings();
    1825        new NotificationCenter();
    19         new SurveyService();
    2026    }
    2127
     
    2733            'manage_options',
    2834            self::WANC_SLUG_MENU,
    29             [new Settings(), 'optionsPage']
     35            [new Settings(), 'optionsPage'],
     36            plugins_url('wp-admin-notification-center/assets/images/logo.svg')
     37        );
     38
     39        add_submenu_page(
     40            self::WANC_SLUG_MENU,
     41            'Notice Listing',
     42            'Notice Listing',
     43            'manage_options',
     44            'notice-listing',
     45            [new Notices(), 'listing']
    3046        );
    3147    }
     48
     49    public function addScript() {
     50        wp_enqueue_style('wanc_style', plugins_url('wp-admin-notification-center/assets/css/global.css?time='.time()));
     51    }
    3252}
  • wp-admin-notification-center/trunk/assets/js/notice.js

    r2900860 r2994668  
    33    preAdminNotifications: '',
    44    adminNotifications: [],
     5    notificationsDisplayed: [],
    56    buttonNotification: '',
    67    closeButton: '',
     
    4243        setTimeout(() => {
    4344            this.moveNotifications();
     45            this.saveNotices();
    4446        }, 500);
    4547    },
    4648    initNotificationCenterStyle: function () {
    4749        //We get the top and left to place it
    48         let top = this.buttonNotification.offsetTop + this.buttonNotification.offsetHeight;
     50        const top = this.buttonNotification.offsetTop + this.buttonNotification.offsetHeight;
    4951
    50         let paddingTopContainer = document.defaultView.getComputedStyle(this.wancContainer, '').getPropertyValue('padding-top').replace(/[^-\d\.]/g, '');
     52        const paddingTopContainer = document.defaultView.getComputedStyle(this.wancContainer, '').getPropertyValue('padding-top').replace(/[^-\d\.]/g, '');
    5153
    5254        //We place it
     
    8284            //We display it if this is a not a crucial notification
    8385            this.wancContainer.appendChild(this.adminNotifications[i]);
     86            this.notificationsDisplayed.push(this.adminNotifications[i]);
    8487
    8588            if (this.wancContainer.lastChild.offsetHeight > 0) numberOfNotification++;
     
    111114    },
    112115    needToBeDisplayed: function (notification) {
    113         //let's run the settings and check if there something to display
     116        //let's run the settings and check if there is something to display
    114117        for (let [noticeClass, displayNotice] of Object.entries(this.notificationSettings)) {
    115118            if (displayNotice !== 1 && notification.classList.contains(noticeClass)) return true;
     
    130133
    131134        // we set a nice array by removing all white space at the start and the end of each word
    132         let formattedWords = [];
     135        const formattedWords = [];
    133136        this[option].map(word => {
    134137            formattedWords.push(word.trim());
     
    151154            if (notWhiteListed) this.adminNotifications.push(this.preAdminNotifications[i]);
    152155        }
     156    },
     157    saveNotices: function () {
     158        const formData = new FormData();
     159
     160        formData.set('action', 'save_notices');
     161        this.notificationsDisplayed.forEach((notice, index) => {
     162            formData.set(`notices[${index}]`, JSON.stringify(notice.outerHTML));
     163        });
     164
     165        fetch(ajaxurl, {method: 'POST', body: formData}).then(response => {
     166            return response.text();
     167        });
    153168    }
    154169};
  • wp-admin-notification-center/trunk/assets/js/notice_not_allowed.js

    r2375266 r2994668  
    11const wanc_notification_not_allowed = {
    22    init: function () {
    3         let adminNotifications = document.querySelectorAll('.notice, #message');
     3        const adminNotifications = document.querySelectorAll('.notice, #message');
    44        for (let i = 0 ; i < adminNotifications.length ; i++) {
    55            adminNotifications[i].remove();
  • wp-admin-notification-center/trunk/index.php

    r2966106 r2994668  
    66Author URI: https://github.com/roumilb
    77License: GPLv3
    8 Version: 2.3.3
     8Version: 3.0.0
    99Text Domain: wanc
    1010Domain Path: /languages
  • wp-admin-notification-center/trunk/lib/Debug.php

    r2771298 r2994668  
    11<?php
    22
    3 
    4 namespace WANC\lib;
    5 
     3namespace WANC;
    64
    75class Debug
  • wp-admin-notification-center/trunk/readme.txt

    r2966106 r2994668  
    33Tags: notification, notice, notices, notifications, admin
    44Requires at least: 5.0
    5 Tested up to: 6.2
     5Tested up to: 6.4
    66Requires PHP: 7.0
    7 Stable tag: 2.3.3
     7Stable tag: 3.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3535== Changelog ==
    3636
    37 = 2.3.3 =
    38 * Fix CSRF Vulnerability
     37= 3.0.0 =
     38* Store notice displayed in the admin
     39* Listing of all notices stored
     40* Change admin menu icon
  • wp-admin-notification-center/trunk/src/Init.php

    r2900859 r2994668  
    44namespace WANC;
    55
    6 use \WANC\Controllers\Settings;
    7 use \WANC\Controllers\NotificationCenter;
    8 use WANC\Services\SurveyService;
     6use WANC\Controllers\Notices;
     7use WANC\Controllers\Settings;
     8use WANC\Controllers\NotificationCenter;
     9use WANC\Services\UpdateService;
    910
    1011class Init
     
    1415    public function __construct()
    1516    {
     17        if (is_admin()) {
     18            (new UpdateService())->update();
     19        }
     20
    1621        add_action('admin_menu', [$this, 'registerWancOptionsPage']);
     22        add_action('admin_enqueue_scripts', [$this, 'addScript']);
     23        new Notices();
    1724        new Settings();
    1825        new NotificationCenter();
    19         new SurveyService();
    2026    }
    2127
     
    2733            'manage_options',
    2834            self::WANC_SLUG_MENU,
    29             [new Settings(), 'optionsPage']
     35            [new Settings(), 'optionsPage'],
     36            plugins_url('wp-admin-notification-center/assets/images/logo.svg')
     37        );
     38
     39        add_submenu_page(
     40            self::WANC_SLUG_MENU,
     41            'Notice Listing',
     42            'Notice Listing',
     43            'manage_options',
     44            'notice-listing',
     45            [new Notices(), 'listing']
    3046        );
    3147    }
     48
     49    public function addScript() {
     50        wp_enqueue_style('wanc_style', plugins_url('wp-admin-notification-center/assets/css/global.css?time='.time()));
     51    }
    3252}
Note: See TracChangeset for help on using the changeset viewer.