Skip to content

Commit

Permalink
Notices only appear for admins
Browse files Browse the repository at this point in the history
  • Loading branch information
morceaudebois committed Sep 25, 2023
1 parent bb5f050 commit dbf577c
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 73 deletions.
6 changes: 3 additions & 3 deletions debrandify.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php if (!defined('ABSPATH')) { exit; }
/**
* @package Debrandify
* @version 1.1.0
* @version 1.1.1
*/
/*
Plugin Name: Debrandify
Version: 1.1.0
Version: 1.1.1
Author: Tahoe Beetschen
Author URI: https://tahoe.be
Plugin URI: https://github.com/morceaudebois/debrandify
Domain Path: languages/
Text Domain: debrandify
Description: Debrandify is a simple WordPress plugin that lets you hide WordPress' branding and replace it with yours as well as make your site lighter.
Description: Debrandify is a simple WordPress plugin that lets you hide WordPress' branding and replace it with yours.
License: GPL2
*/
Expand Down
24 changes: 12 additions & 12 deletions languages/dbrdify.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPL2.
msgid ""
msgstr ""
"Project-Id-Version: Debrandify 1.1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/DeWordPressify\n"
"Project-Id-Version: Debrandify 1.1.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/debrandify\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-07-23T13:56:38+00:00\n"
"POT-Creation-Date: 2023-09-25T11:24:12+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Domain: debrandify\n"
Expand All @@ -23,7 +23,7 @@ msgid "https://github.com/morceaudebois/debrandify"
msgstr ""

#. Description of the plugin
msgid "Debrandify is a simple WordPress plugin that lets you hide WordPress' branding and replace it with yours as well as make your site lighter."
msgid "Debrandify is a simple WordPress plugin that lets you hide WordPress' branding and replace it with yours."
msgstr ""

#. Author of the plugin
Expand All @@ -34,36 +34,36 @@ msgstr ""
msgid "https://tahoe.be"
msgstr ""

#: debrandify.php:192
#: debrandify.php:198
msgid "No feed available, please visit the "
msgstr ""

#: debrandify.php:194
#: debrandify.php:200
msgid "homepage"
msgstr ""

#: debrandify.php:375
#: debrandify.php:381
msgid "The WordPress REST API has been disabled."
msgstr ""

#: src/php/notices.php:26
#: src/php/notices.php:78
#: src/php/notices.php:81
msgid "Donate"
msgstr ""

#: src/php/notices.php:40
#: src/php/notices.php:41
msgid "Thank you for installing <b>Debrandify</b>! You can start getting rid of WordPress' branding right away."
msgstr ""

#: src/php/notices.php:42
#: src/php/notices.php:43
msgid "Visit settings page"
msgstr ""

#: src/php/notices.php:75
#: src/php/notices.php:78
msgid "You've been using Debrandify for a while now, I hope you like it! If so, please consider giving a review or donating, that would help a lot 😊"
msgstr ""

#: src/php/notices.php:77
#: src/php/notices.php:80
msgid "Review"
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "debrandify",
"version": "1.0.0",
"version": "1.1.1",
"description": "<h1 align=\"center\"> <a href=\"https://tahoe.be\"><img src=\"https://raw.githubusercontent.com/morceaudebois/debrandify/master/src/images/debrandify.png\" width=\"80%\" alt=\"\"></a> </h1>",
"main": "script.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ I love making high quality open source software! My goal is to become a full tim
- [x] Block library toggle
- [ ] Animated logo (mayyyyybe)
- [x] Translation file + french translation
- [ ] Publish on WordPress!
- [x] Publish on WordPress!

<br>

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://ko-fi.com/tahoe
Tags: branding, rebrand, rebranding, customise, lightweight, minimalism, cleanup, remove
Requires at least: 4.7
Tested up to: 6.2
Stable tag: 1.1.0
Stable tag: 1.1.1
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
110 changes: 57 additions & 53 deletions src/php/notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,59 +30,63 @@
} return $plugin_meta;
}, 10, 3);

// manages banners
if (get_option('dbrdify_installBanner') == 'toBeTriggered') {
add_action('admin_notices', function() { ?>
<div class="notice notice-success is-dismissible" style="display: flex; flex-direction: row; align-items: center;">
if (current_user_can('activate_plugins')) {
// manages banners
if (get_option('dbrdify_installBanner') == 'toBeTriggered') {
add_action('admin_notices', function() { ?>
<div class="notice notice-success is-dismissible" style="display: flex; flex-direction: row; align-items: center;">

<img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../images/bin.png') ?>" alt="" style="max-height: 70px; height: auto; margin: 10px 15px 10px 0px">
<img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../images/bin.png') ?>" alt="" style="max-height: 70px; height: auto; margin: 10px 15px 10px 0px">

<p><?php _e('Thank you for installing <b>Debrandify</b>! You can start getting rid of WordPress\' branding right away.', 'debrandify')?><br>

<a class="button" href="<?php menu_page_url('debrandify')?>" style="margin-top: 8px"><?php _e('Visit settings page', 'debrandify') ?></a></p>
<p><?php _e('Thank you for installing <b>Debrandify</b>! You can start getting rid of WordPress\' branding right away.', 'debrandify')?><br>

</div>
<?php });

update_option('dbrdify_installBanner', 'triggered');

// change to +30 days to debug notice
} else if (get_option('dbrdify_installDate') < strtotime('-30 days') && empty(get_option('dbrdify_usedNotice'))) {

add_action('admin_notices', function() { ?>

<script type="text/javascript">
window.addEventListener('DOMContentLoaded', () => {
document.querySelector('#used_banner .notice-dismiss').onclick = function() {
document.querySelector('#used_banner').remove();

fetch('<?php echo esc_url(get_option('siteurl') . "/wp-admin/admin-ajax.php") ?>', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: 'action=used_notice'
}).catch(console.error)

};
})
</script>

<div class="notice" id="used_banner" style="display: flex; flex-direction: row; align-items: center; position: relative;">
<img src="<?php echo esc_url((plugin_dir_url(__FILE__) . '../images/bin.png')) ?>" alt="" style="max-height: 70px; height: auto; margin: 10px 15px 10px 0px">

<p style="margin-right: 10px">
<?php _e('You\'ve been using Debrandify for a while now, I hope you like it! If so, please consider giving a review or donating, that would help a lot 😊', 'debrandify')?><br>

<a class="button" href="https://wordpress.org/plugins/debrandify/#reviews" style="margin-top: 8px; margin-right: 5px;"><?php _e('Review', 'debrandify') ?></a>
<a class="button" href="https://ko-fi.com/tahoe" style="margin-top: 8px"><?php _e('Donate', 'debrandify') ?></a>
</p>

<!-- added button manually instead of with
.is-dismissible otherwise onclick doesn't work -->
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Ignore this notification.</span>
</button>
</div>
<?php });
}
<a class="button" href="<?php menu_page_url('debrandify')?>" style="margin-top: 8px"><?php _e('Visit settings page', 'debrandify') ?></a></p>

</div>
<?php });

update_option('dbrdify_installBanner', 'triggered');

// change to +30 days to debug notice
} else if (get_option('dbrdify_installDate') < strtotime('-30 days') && empty(get_option('dbrdify_usedNotice'))) {

add_action('admin_notices', function() { ?>

<script type="text/javascript">
window.addEventListener('DOMContentLoaded', () => {
document.querySelector('#used_banner .notice-dismiss').onclick = function() {
document.querySelector('#used_banner').remove();

fetch('<?php echo esc_url(get_option('siteurl') . "/wp-admin/admin-ajax.php") ?>', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: 'action=used_notice'
}).catch(console.error)

};
})
</script>

<div class="notice" id="used_banner" style="display: flex; flex-direction: row; align-items: center; position: relative;">
<a href="<?php echo esc_url(get_option('siteurl') . "/wp-admin/options-general.php?page=debrandify") ?>">
<img src="<?php echo esc_url((plugin_dir_url(__FILE__) . '../images/bin.png')) ?>" alt="" style="max-height: 70px; height: auto; margin: 10px 15px 10px 0px">
</a>

<p style="margin-right: 10px">
<?php _e('You\'ve been using Debrandify for a while now, I hope you like it! If so, please consider giving a review or donating, that would help a lot 😊', 'debrandify')?><br>

<a class="button" href="https://wordpress.org/plugins/debrandify/#reviews" style="margin-top: 8px; margin-right: 5px;"><?php _e('Review', 'debrandify') ?> ⭐️</a>
<a class="button" href="https://ko-fi.com/tahoe" style="margin-top: 8px"><?php _e('Donate', 'debrandify') ?> 🙏</a>
</p>

<!-- added button manually instead of with
.is-dismissible otherwise onclick doesn't work -->
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Ignore this notification.</span>
</button>
</div>
<?php });
}
}

0 comments on commit dbf577c

Please sign in to comment.