Preparing plugin for WordPress Plugin Directory
Create and add plugin assets, comment code, update README, create `readme.txt` for WP repo.
This commit is contained in:
parent
83ea44c377
commit
5d5262701d
20
README.md
20
README.md
@ -10,8 +10,24 @@ To install this plugin, drop `biscotti.php` into your site's `wp-content/plugins
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Once activated, a new option will be available in the WordPress dashboard under "User -> Profile" called "Login Cookie Expiration". There, you can select the cookie expiration date of 3 months, 6 months, or 1 year on a per-account basis.
|
Once the plugin has been activated, a new option will be available in the WordPress dashboard under "User -> Profile" called "Login Cookie Expiration". There, you can select the cookie expiration date of 3 months, 6 months, or 1 year on a per-account basis.
|
||||||
|
|
||||||
After updating this setting, you _will_ need to log out and back into WordPress for your new cookie expiration value to take effect.
|
After updating this setting, you *will* need to log out and back into WordPress for your new cookie expiration value to take effect.
|
||||||
|
|
||||||
Enjoy your long cookie!
|
Enjoy your long cookie!
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
### 2.0.0
|
||||||
|
|
||||||
|
Rewrite! Now, instead of forcing *everyone* to use the same login cookie expiration, Biscotti allows users to individually select their login cookie expiration on their profile page.
|
||||||
|
|
||||||
|
### 1.0.0
|
||||||
|
|
||||||
|
Initial release. Simple plugin that forced login cookie expiration for every user to 1 year.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
All plugin code is (currently) Jason Cosper's fault.
|
||||||
|
Plugin header image courtesy of Terri Bateman.
|
||||||
|
Plugin icon courtesy of Toora Khan from Noun Project.
|
BIN
assets/banner-1544x500.jpg
Normal file
BIN
assets/banner-1544x500.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
BIN
assets/banner-772x250.jpg
Normal file
BIN
assets/banner-772x250.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
assets/icon-128x128.png
Normal file
BIN
assets/icon-128x128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
BIN
assets/icon-256x256.png
Normal file
BIN
assets/icon-256x256.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
25
biscotti.php
25
biscotti.php
@ -8,18 +8,18 @@
|
|||||||
*
|
*
|
||||||
* @package Biscotti
|
* @package Biscotti
|
||||||
* @author Jason Cosper <boogah@gmail.com>
|
* @author Jason Cosper <boogah@gmail.com>
|
||||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
|
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
|
||||||
* @link https://github.com/boogah/biscotti
|
* @link https://github.com/boogah/biscotti
|
||||||
*
|
*
|
||||||
* @wordpress-plugin
|
* @wordpress-plugin
|
||||||
* Plugin Name: Biscotti
|
* Plugin Name: Biscotti
|
||||||
* Plugin URI: https://github.com/boogah/biscotti
|
* Plugin URI: https://github.com/boogah/biscotti
|
||||||
* Description: Biscotti makes your login cookie a little bit longer.
|
* Description: Biscotti makes your user's login cookie a little bit longer.
|
||||||
* Version: 2.0.0
|
* Version: 2.0.0
|
||||||
* Author: Jason Cosper
|
* Author: Jason Cosper
|
||||||
* Author URI: https://jasoncosper.com/
|
* Author URI: https://jasoncosper.com/
|
||||||
* License: GPL-2.0+
|
* License: GPL-2.0+
|
||||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// If this file is called directly, abort.
|
// If this file is called directly, abort.
|
||||||
@ -27,9 +27,9 @@ if (! defined('WPINC') ) {
|
|||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a dropdown menu to the user profile page that allows you to choose the login cookie's expiration date.
|
||||||
function biscotti_login_cookie_expiration_form_fields( $user )
|
function biscotti_login_cookie_expiration_form_fields( $user )
|
||||||
{
|
{
|
||||||
// Add a dropdown menu to the user profile page that allows you to choose the login cookie's expiration date.
|
|
||||||
$expiration_options = array(
|
$expiration_options = array(
|
||||||
'3 months' => '3 months',
|
'3 months' => '3 months',
|
||||||
'6 months' => '6 months',
|
'6 months' => '6 months',
|
||||||
@ -54,9 +54,12 @@ function biscotti_login_cookie_expiration_form_fields( $user )
|
|||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the form fields to the user profile page.
|
||||||
add_action('show_user_profile', 'biscotti_login_cookie_expiration_form_fields');
|
add_action('show_user_profile', 'biscotti_login_cookie_expiration_form_fields');
|
||||||
add_action('edit_user_profile', 'biscotti_login_cookie_expiration_form_fields');
|
add_action('edit_user_profile', 'biscotti_login_cookie_expiration_form_fields');
|
||||||
|
|
||||||
|
// Update the user meta with the chosen login cookie expiration date.
|
||||||
function biscotti_login_cookie_expiration_form_fields_update( $user_id )
|
function biscotti_login_cookie_expiration_form_fields_update( $user_id )
|
||||||
{
|
{
|
||||||
if (! current_user_can('edit_user', $user_id) ) {
|
if (! current_user_can('edit_user', $user_id) ) {
|
||||||
@ -64,9 +67,12 @@ function biscotti_login_cookie_expiration_form_fields_update( $user_id )
|
|||||||
}
|
}
|
||||||
update_user_meta($user_id, 'biscotti_login_cookie_expiration', $_POST['biscotti_login_cookie_expiration']);
|
update_user_meta($user_id, 'biscotti_login_cookie_expiration', $_POST['biscotti_login_cookie_expiration']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the chosen login cookie expiration date when the user profile is updated.
|
||||||
add_action('personal_options_update', 'biscotti_login_cookie_expiration_form_fields_update');
|
add_action('personal_options_update', 'biscotti_login_cookie_expiration_form_fields_update');
|
||||||
add_action('edit_user_profile_update', 'biscotti_login_cookie_expiration_form_fields_update');
|
add_action('edit_user_profile_update', 'biscotti_login_cookie_expiration_form_fields_update');
|
||||||
|
|
||||||
|
// Modify the expiration of the logged in user cookie.
|
||||||
function biscotti_login_cookie_expiration_set_auth_cookie( $auth_cookie_data )
|
function biscotti_login_cookie_expiration_set_auth_cookie( $auth_cookie_data )
|
||||||
{
|
{
|
||||||
$user_id = $auth_cookie_data[0];
|
$user_id = $auth_cookie_data[0];
|
||||||
@ -74,17 +80,18 @@ function biscotti_login_cookie_expiration_set_auth_cookie( $auth_cookie_data )
|
|||||||
|
|
||||||
if (! empty($expiration_time) ) {
|
if (! empty($expiration_time) ) {
|
||||||
if ($expiration_time == '3 months' ) {
|
if ($expiration_time == '3 months' ) {
|
||||||
$expiration = 90 * DAY_IN_SECONDS; // 3 months
|
$expiration = 90 * DAY_IN_SECONDS; // Set expiration to 3 months.
|
||||||
} elseif ($expiration_time == '6 months' ) {
|
} elseif ($expiration_time == '6 months' ) {
|
||||||
$expiration = 180 * DAY_IN_SECONDS; // 6 months
|
$expiration = 180 * DAY_IN_SECONDS; // Set expiration to 6 months
|
||||||
} elseif ($expiration_time == '1 year' ) {
|
} elseif ($expiration_time == '1 year' ) {
|
||||||
$expiration = 365 * DAY_IN_SECONDS; // 1 year
|
$expiration = 365 * DAY_IN_SECONDS; // Set expiration to 1 year.
|
||||||
} else {
|
} else {
|
||||||
$expiration = ''; // use default expiration
|
$expiration = ''; // Use default expiration of 14 days.
|
||||||
}
|
}
|
||||||
$auth_cookie_data[2] = $expiration;
|
$auth_cookie_data[2] = $expiration;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $auth_cookie_data;
|
return $auth_cookie_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modify the expiration of the logged in user cookie when a user logs into the site.
|
||||||
add_filter('auth_cookie_expiration', 'biscotti_login_cookie_expiration_set_auth_cookie', 10, 3);
|
add_filter('auth_cookie_expiration', 'biscotti_login_cookie_expiration_set_auth_cookie', 10, 3);
|
40
readme.txt
Normal file
40
readme.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
=== Biscotti ===
|
||||||
|
Contributors: boogah
|
||||||
|
Donate link: http://paypal.me/boogah
|
||||||
|
Tags: login, cookies, profile
|
||||||
|
Requires at least: 6.0
|
||||||
|
Tested up to: 6.1.1
|
||||||
|
Stable tag: 2.0.0
|
||||||
|
Requires PHP: 7.4
|
||||||
|
License: GPLv2 or later
|
||||||
|
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
|
|
||||||
|
Biscotti makes your user's login cookie a little bit longer.
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
Biscotti is a plugin that modifies the expiration of the logged in user cookie in WordPress to three months, six months, or one year. Because some people hate to have to keep entering their passwords.
|
||||||
|
|
||||||
|
== Installation ==
|
||||||
|
|
||||||
|
To install this plugin, drop `biscotti.php` into your site\'s `wp-content/plugins` directory and activate it.
|
||||||
|
|
||||||
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
|
= How do I work this thing? =
|
||||||
|
|
||||||
|
Once the plugin has been activated, a new option will be available in the WordPress dashboard under "User -> Profile" called "Login Cookie Expiration". There, you can select the cookie expiration date of 3 months, 6 months, or 1 year on a per-account basis.
|
||||||
|
|
||||||
|
After updating this setting, you *will* need to log out and back into WordPress for your new cookie expiration value to take effect.
|
||||||
|
|
||||||
|
Enjoy your long cookie!
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
|
||||||
|
= 2.0.0 =
|
||||||
|
|
||||||
|
Rewrite! Now, instead of forcing *everyone* to use the same login cookie expiration, Biscotti allows users to individually select their login cookie expiration on their profile page.
|
||||||
|
|
||||||
|
= 1.0.0 =
|
||||||
|
|
||||||
|
Initial release. Simple plugin that forced login cookie expiration for every user to 1 year.
|
Loading…
x
Reference in New Issue
Block a user