Utility PHP class to simplify interacting with persistent dismissible WordPress notices, promos, and banners

Overview

Persistent Dismissible

A class for encapsulating the logic required to maintain a relationship between the database, a dismissible UI element (with an optional lifespan), and a user's desire to dismiss that UI element.

Think of this like a WordPress Transient, but without in-memory cache support, and that uses the wp_usermeta database table instead of wp_options.

We invented this utility to centralize and minimize the code required to execute multiple different calls and checks to the User Meta and User Options APIs inside of WordPress Core.

We use this as the engine to power if and when we should show persistent admin-area notices to logged-in WordPress users. Dismissals can be set to expire after some number of seconds. They are global by default in a multisite environment, but can be per-site. Custom values can be saved if necessary.

Setup

Include in your plugin or theme however you feel is best.

Use with a PHP use statement:

use Sandhills\Utils\Persistent_Dismissible as PD;

Set

PD::set( [
	'id' => 'sh_dismissible_promotion_xyz'
] );

Get

$is_dismissed = PD::get( [
	'id' => 'sh_dismissible_promotion_xyz'
] );

Delete

PD::delete( [
	'id' => 'sh_dismissible_promotion_xyz'
] );

Arguments

/**
 * @param array|string $args {
 *     Array or string of arguments to identify the persistent dismissible.
 *
 *     @type string      $id       Required. ID of the persistent dismissible.
 *     @type string      $user_id  Optional. User ID. Default to current user ID.
 *     @type int|string  $value    Optional. Value to store. Default to true.
 *     @type int|string  $life     Optional. Lifespan. Default to 0 (infinite)
 *     @type bool        $global   Optional. Multisite, all sites. Default true.
 * }
 */

This project was created by (and is managed by) Sandhills Development, LLC, where we aim to craft superior experiences through ingenuity, with deep commitment to (and appreciation for) the human element.

You might also like...
It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session and API Authentication

About Auth Starter It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session an

Tech-Admin is Laravel + Bootstrap Admin Panel With User Management And Access Control based on Roles and Permissions.
Tech-Admin is Laravel + Bootstrap Admin Panel With User Management And Access Control based on Roles and Permissions.

Tech-Admin | Laravel 8 + Bootstrap 4 Tech-Admin is Admin Panel With Preset of Roles, Permissions, ACL, User Management, Profile Management. Features M

Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use

Introduction Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use. Official Documentation Documenta

PHP package built for Laravel 5.* to easily handle a user email verification and validate the email

jrean/laravel-user-verification is a PHP package built for Laravel 5.* & 6.* & 7.* & 8.* to easily handle a user verification and validate the e-mail.

Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.
Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.

What is Kaiju? Kaiju is an open source verification bot for Discord servers, based on OAuth and with permission for the server owner, to be able to mi

A whitelabeled and modernized wp-login.php
A whitelabeled and modernized wp-login.php

Modern Login Here lives a simple mu-plugin to whitelabel and modernize wp-login.php. No admin panels, no bloat – just a simple filter to optionally cu

This is registration and authentication forms written in PHP, JQuery
This is registration and authentication forms written in PHP, JQuery

Registration-form This is registration and authentication forms written in PHP, JQuery Each file is: header.php - html-file for links "Главная", "Реги

PHP Login and Registration Script

dj_login PHP Login and Registration Script To function this script requires you put your MySQL info into both login.php and register.php, and have the

A PHP boilerplate based on Slim Framework, for start projects with Eloquent ORM, Validation, Auth (JWT), Repositories and Transformers ready

A PHP boilerplate based on Slim Framework, for start projects with Eloquent ORM, Validation, Auth (JWT), Repositories and Transformers ready.

Comments
  • class_exists() check needs to include namespace

    class_exists() check needs to include namespace

    https://github.com/sandhillsdevelopment/persistent-dismissible/blob/main/src/persistent-dismissible.php#L17

    Should be:

    if ( ! class_exists( 'Sandhills\Utils\Persistent_Dismissible' ) ) :
    
    bug 
    opened by ashleyfae 0
  • Improve check_args()

    Improve check_args()

    The check_args() method is intentionally lenient with its approach to operation validation. It probably should be better.

    Briefly:

    • sanitize_key() on ID
    • absint() on life
    • absint() on user ID
    opened by JJJ 0
Releases(1.0.0)
Owner
Sandhills Development, LLC
We build open source software and products like @easydigitaldownloads, @AffiliateWP, @wpsimplepay and @sugarcalendar
Sandhills Development, LLC
PHPAuth is a secure PHP Authentication class that easily integrates into any site.

PHPAuth is under going a complete rewrite to bring the code up to date, the project has been on hold for way to long time now and I decided to work on it again making sure EVERYONE can use it and not just advanced programmers.

PHPAuth 855 Jan 3, 2023
Secure WordPress login with two factor authentication

This plugin allows you to secure your WordPress login with two factor authentication. The users will have to enter a one time password every time they log in.

Volodymyr Kolesnykov 6 Nov 2, 2022
Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

Hybridauth 3.7.1 Hybridauth enables developers to easily build social applications and tools to engage websites visitors and customers on a social lev

hybridauth 3.3k Dec 23, 2022
PHP library to verify and validate Apple IdentityToken and authenticate a user with Apple ID.

Sign-in with Apple SDK Installation Recommended and easiest way to installing library is through Composer. composer require azimolabs/apple-sign-in-ph

Azimo Labs 79 Nov 8, 2022
PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging

Thruway is an open source client and router implementation of WAMP (Web Application Messaging Protocol), for PHP. Thruway uses an event-driven, non-blocking I/O model (reactphp), perfect for modern real-time applications.

Voryx 662 Jan 3, 2023
UserFrosting is a secure, modern user management system written in PHP and built on top of the Slim Microframework, Twig templating engine, and Eloquent ORM.

UserFrosting is a secure, modern user management system written in PHP and built on top of the Slim Microframework, Twig templating engine, and Eloquent ORM.

UserFrosting 1.6k Jan 1, 2023
User registration and login form with validations and escapes for total security made with PHP.

Login and Sign Up with PHP User registration and login form with validations and escapes for total security made with PHP. Validations Required fields

Alexander Pérez 2 Jan 26, 2022
A complete Login and Register page using a Mysql Database and php

Login With Mysql A complete Login and Register page using a Mysql Database ?? Built with ⚙️ ?? Description A login with Frontend, Backend and Database

Marc Medrano 1 Nov 5, 2021
A Native PHP MVC With Auth. If you will build your own PHP project in MVC with router and Auth, you can clone this ready to use MVC pattern repo.

If you will build your own PHP project in MVC with router and Auth, you can clone this ready to use MVC pattern repo. Auth system is implemented. Works with bootstrap 5. Composer with autoload are implemented too for future composer require.

null 2 Jun 6, 2022
Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system.

Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system. Built on Bootstrap 4.

Jeremy Kenedy 2.8k Dec 31, 2022