Skip to content

Instantly share code, notes, and snippets.

grola grola

Block or report user

Report or block grola

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View dismissible-notice.php
<?php
wpdesk_permanent_dismissible_notice( 'Success notice.', 'my-success-notice', 'success' );
View init-ajax-handler.php
<?php
wpdesk_init_notice_ajax_handler();
View display-notices.php
<?php
wpdesk_notice_success( 'Success notice.' );
wpdesk_notice_info( 'Info notice.' );
wpdesk_notice_warning( 'Warning notice.' );
wpdesk_notice_error( 'Error notice.' );
View include-init.php
<?php
require_once 'wp-desk/wp-notice/init.php';
View include-autoloader.php
<?php
require_once 'vendor/autoload.php';
View composer-require.sh
composer require wpdesk/wp-notice
@grola
grola / dismissible-ajax-notice.php
Created Jan 15, 2019
Dismissible notice with AJAX
View dismissible-ajax-notice.php
<?php
function wpdesk_permanent_dismisible_info_notice_for_administrator() {
$notice name = 'admin_notice';
if ( intval( get_option( 'wpdesk_notice_dismiss_' . $notice_name, 0 ) ) !== 1 ) {
$user = wp_get current_user();
if ( in_array( 'administrator', $user->roles ) ) {
?>
<div class="notice notice-info is-dismissible" data-notice-name="<?php echo $notice_name; ?>">
<p>Info notice for administrator.</p>
View dismissible-notice.php
<?php
function wpdesk_dismisible_info_notice_for_administrator() {
$user = wp_get current_user();
if ( in_array( 'administrator', $user->roles ) ) {
?>
<div class="notice notice-info is-dismissible">
<p>Info notice for administrator.</p>
</div>
<?php
View conditional-notice.php
<?php
function wpdesk_info_notice_for_administrator() {
$user = wp_get current_user();
if ( in_array( 'administrator', $user->roles ) ) {
?>
<div class="notice notice-info">
<p>Info notice for administrator.</p>
</div>
<?php
View info-notice.php
<?php
function wpdesk_info_notice() {
?>
<div class="notice notice-info">
<p>Info notice.</p>
</div>
<?php
}
add_action( 'admin_notices', 'wpdesk_info_notice' );
You can’t perform that action at this time.