Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,301 @@
<?php
/**
* Admin side functionality of the plugin.
*
* @link https://thefoxe.com/products/loggedin
* @license http://www.gnu.org/licenses/ GNU General Public License
* @category Core
* @package Loggedin
* @subpackage Admin
* @author Joel James <me@joelsays.com>
*/
// If this file is called directly, abort.
defined( 'WPINC' ) || die( 'Well, get lost.' );
/**
* Class Loggedin_Admin
*/
class Loggedin_Admin {
/**
* Initialize the class and set its properties.
*
* We register all our admin hooks here.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function __construct() {
// Set options page.
add_action( 'admin_init', array( $this, 'options_page' ) );
// Set options page.
add_action( 'admin_init', array( $this, 'force_logout' ) );
// Show review request.
add_action( 'admin_notices', array( $this, 'review_notice' ) );
add_action( 'admin_init', array( $this, 'review_action' ) );
}
/**
* Process the force logout action.
*
* This will force logout the user from all devices.
*
* @since 1.1.0
* @access public
*
* @return void
*/
public function force_logout() {
// If force logout submit.
if ( isset( $_REQUEST['loggedin_logout'] ) && isset( $_REQUEST['loggedin_user'] ) ) {
// Security check.
check_admin_referer( 'general-options' );
// Get user.
$user = get_userdata( (int) $_REQUEST['loggedin_user'] );
if ( $user ) {
// Sessions token instance.
$manager = WP_Session_Tokens::get_instance( $user->ID );
// Destroy all sessions.
$manager->destroy_all();
// Add success message.
add_settings_error(
'general',
'settings_updated', // Override the settings update message.
sprintf(
// translators: %s User name of the logging out user.
__( 'User %s forcefully logged out from all devices.', 'loggedin' ),
$user->user_login
),
'updated'
);
} else {
// Add success message.
add_settings_error(
'general',
'settings_updated', // Override the settings update message.
sprintf(
// translators: %d User ID of the login user.
__( 'Invalid user ID: %d', 'loggedin' ),
intval( $_REQUEST['loggedin_user'] )
)
);
}
}
}
/**
* Create new option field label to the default settings page.
*
* @since 1.0.0
* @access public
* @uses register_setting() To register new setting.
* @uses add_settings_field() To add new field to for the setting.
*
* @return void
*/
public function options_page() {
// Add new settings section.
add_settings_section(
'loggedin_settings',
'🔐 Loggedin Settings',
'',
'general'
);
// Register limit settings.
register_setting( 'general', 'loggedin_maximum' );
// Register logic settings.
register_setting( 'general', 'loggedin_logic' );
// Add new setting filed to set the limit.
add_settings_field(
'loggedin_maximum',
'<label for="loggedin_maximum">' . __( 'Maximum Active Logins', 'loggedin' ) . '</label>',
array( &$this, 'loggedin_maximum' ),
'general',
'loggedin_settings'
);
// Add new setting filed to set the limit.
add_settings_field(
'loggedin_logic',
'<label for="loggedin_logic">' . __( 'Login Logic', 'loggedin' ) . '</label>',
array( &$this, 'loggedin_logic' ),
'general',
'loggedin_settings'
);
// Add new setting field for force logout.
add_settings_field(
'loggedin_logout',
'<label for="loggedin_logout">' . __( 'Force Logout', 'loggedin' ) . '</label>',
array( &$this, 'loggedin_logout' ),
'general',
'loggedin_settings'
);
}
/**
* Create new options field to show the limit settings.
*
* @since 1.0.0
* @access public
* @uses get_option() To get the option value.
*
* @return void
*/
public function loggedin_maximum() {
// Get settings value.
$value = get_option( 'loggedin_maximum', 3 );
echo '<p><input type="number" name="loggedin_maximum" id="loggedin_maximum" min="1" value="' . intval( $value ) . '" placeholder="' . esc_html__( 'Enter the limit in number', 'loggedin' ) . '" /></p>';
echo '<p class="description">' . esc_html__( 'Set the maximum no. of active logins a user account can have.', 'loggedin' ) . '</p>';
echo '<p class="description">' . esc_html__( 'If this limit reached, next login request will be failed and user will have to logout from one device to continue.', 'loggedin' ) . '</p>';
echo '<p class="description"><strong>' . esc_html__( 'Note: ', 'loggedin' ) . '</strong>' . esc_html__( 'Even if the browser is closed, login session may exist.', 'loggedin' ) . '</p>';
}
/**
* Create new options field to show the.
*
* @since 1.2.0
* @access public
* @uses get_option() To get the option value.
*
* @return void
*/
public function loggedin_logic() {
// Get settings value.
$value = get_option( 'loggedin_logic', 'allow' );
echo '<input type="radio" name="loggedin_logic" value="allow" ' . checked( $value, 'allow', false ) . '/> ' . esc_html__( 'Allow', 'loggedin' );
echo ' <input type="radio" name="loggedin_logic" value="block" ' . checked( $value, 'block', false ) . '/> ' . esc_html__( 'Block', 'loggedin' );
echo '<p class="description"><strong>' . esc_html__( 'Allow:', 'loggedin' ) . '</strong> ' . esc_html__( 'Allow new login by terminating all other old sessions when the limit is reached.', 'loggedin' ) . '</p>';
echo '<p class="description"><strong>' . esc_html__( 'Block:', 'loggedin' ) . '</strong> ' . esc_html__( ' Do not allow new login if the limit is reached. Users need to wait for the old login sessions to expire.', 'loggedin' ) . '</p>';
}
/**
* Create new options field to the settings page.
*
* @since 1.0.0
* @access public
* @uses get_option() To get the option value.
*
* @return void
*/
public function loggedin_logout() {
echo '<input type="number" name="loggedin_user" min="1" placeholder="' . esc_html__( 'Enter user ID', 'loggedin' ) . '" />';
echo ' <input type="submit" name="loggedin_logout" id="loggedin_logout" class="button" value="' . esc_html__( 'Force Logout', 'loggedin' ) . '">';
echo '<p class="description">' . esc_html__( 'If you would like to force logout a user from all the devices, enter the user ID.', 'loggedin' ) . '</p>';
}
/**
* Show admin to ask for review in wp.org.
*
* Show admin notice only inside our plugin's settings page.
* Hide the notice permanently if user dismissed it.
*
* @since 1.1.0
*
* @return void|bool
*/
public function review_notice() {
global $pagenow;
// Only on our settings page.
if ( 'options-general.php' === $pagenow ) {
// Only for admins.
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
// Get the notice time.
$notice_time = get_option( 'loggedin_rating_notice' );
// If not set, set now and bail.
if ( ! $notice_time ) {
// Set to next week.
return add_option( 'loggedin_rating_notice', time() + 604800 );
}
// Current logged in user.
$current_user = wp_get_current_user();
// Did the current user already dismiss?.
$dismissed = get_user_meta( $current_user->ID, 'loggedin_rating_notice_dismissed', true );
// Continue only when allowed.
if ( (int) $notice_time <= time() && ! $dismissed ) {
?>
<div class="notice notice-success">
<p>
<?php
printf(
// translators: %1$s Current user's name. %2$s <strong> %3$s </strong>.
__( 'Hey %1$s, I noticed you\'ve been using %2$sLoggedin%3$s plugin for more than 1 week thats awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.', 'loggedin' ),
empty( $current_user->display_name ) ? esc_html__( 'there', 'loggedin' ) : esc_attr( ucwords( $current_user->display_name ) ),
'<strong>',
'</strong>'
);
?>
</p>
<p>
<a href="https://wordpress.org/support/plugin/loggedin/reviews/#new-post" target="_blank">
<?php esc_html_e( 'Ok, you deserve it', 'loggedin' ); ?>
</a>
</p>
<p>
<a href="<?php echo esc_url( add_query_arg( 'loggedin_rating', 'later' ) ); // later. ?>">
<?php esc_html_e( 'Nope, maybe later', 'loggedin' ); ?>
</a>
</p>
<p>
<a href="<?php echo esc_url( add_query_arg( 'loggedin_rating', 'dismiss' ) ); // dismiss link. ?>">
<?php esc_html_e( 'I already did', 'loggedin' ); ?>
</a>
</p>
</div>
<?php
}
}
}
/**
* Handle review notice actions.
*
* If dismissed set a user meta for the current user and do not show again.
* If agreed to review later, update the review timestamp to after 2 weeks.
*
* @since 1.1.0
*
* @return void
*/
public function review_action() {
// Only for admins.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// Get the current review action.
// phpcs:ignore
$action = isset( $_REQUEST['loggedin_rating'] ) ? $_REQUEST['loggedin_rating'] : '';
switch ( $action ) {
case 'later':
// Let's show after another 2 weeks.
update_option( 'loggedin_rating_notice', time() + 1209600 );
break;
case 'dismiss':
// Do not show again to this user.
update_user_meta( get_current_user_id(), 'loggedin_rating_notice_dismissed', 1 );
break;
}
}
}

View File

@@ -0,0 +1,198 @@
<?php
/**
* The main functionality of the plugin.
*
* @link https://duckdev.com/products/loggedin-limit-active-logins/
* @license http://www.gnu.org/licenses/ GNU General Public License
* @category Core
* @package Loggedin
* @subpackage Public
* @author Joel James <me@joelsays.com>
*/
// If this file is called directly, abort.
defined( 'WPINC' ) || die( 'Well, get lost.' );
/**
* Class Loggedin
*
* @since 1.0.0
*/
class Loggedin {
/**
* Initialize the class and set its properties.
*
* We register all our common hooks here.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function __construct() {
// Use authentication filter.
add_filter( 'wp_authenticate_user', array( $this, 'validate_allow_logic' ) );
// Use password check filter.
add_filter( 'check_password', array( $this, 'validate_block_logic' ), 10, 4 );
}
/**
* Validate if the maximum active logins limit reached.
*
* This check happens only after authentication happens and
* the login logic is "Allow".
*
* @param boolean $check User Object/WPError.
* @param string $password Plaintext user's password.
* @param string $hash Hash of the user's password to check against.
* @param int $user_id User ID.
*
* @since 1.0.0
* @access public
*
* @return bool
*/
public function validate_block_logic( $check, $password, $hash, $user_id ) {
// If the validation failed already, bail.
if ( ! $check ) {
return false;
}
// Do not allow new logins.
if ( 'allow' === get_option( 'loggedin_logic', 'allow' ) ) {
// Check if limit exceed.
if ( $this->reached_limit( $user_id ) ) {
// Sessions token instance.
$manager = WP_Session_Tokens::get_instance( $user_id );
// Destroy all others.
$manager->destroy_all();
}
}
return true;
}
/**
* Validate if the maximum active logins limit reached.
*
* This check happens only after authentication happens and
* the login logic is "Block".
*
* @param object $user User Object/WPError.
*
* @since 1.0.0
* @access public
*
* @return object User object or error object.
*/
public function validate_allow_logic( $user ) {
// If login validation failed already, return that error.
if ( is_wp_error( $user ) ) {
return $user;
}
// Only when block method.
if ( 'block' === get_option( 'loggedin_logic', 'allow' ) ) {
// Check if limit exceed.
if ( $this->reached_limit( $user->ID ) ) {
return new WP_Error( 'loggedin_reached_limit', $this->error_message() );
}
}
return $user;
}
/**
* Check if the current user is allowed for another login.
*
* Count all the active logins for the current user annd
* check if that exceeds the maximum login limit set.
*
* @param int $user_id User ID.
*
* @since 1.0.0
* @access public
*
* @return boolean Limit reached or not
*/
private function reached_limit( $user_id ) {
// If bypassed.
if ( $this->bypass( $user_id ) ) {
return false;
}
// Get maximum active logins allowed.
$maximum = intval( get_option( 'loggedin_maximum', 1 ) );
// Sessions token instance.
$manager = WP_Session_Tokens::get_instance( $user_id );
// Count sessions.
$count = count( $manager->get_all() );
// Check if limit reached.
$reached = $count >= $maximum;
/**
* Filter hook to change the limit condition.
*
* @param bool $reached Reached.
* @param int $user_id User ID.
* @param int $count Active logins count.
*
* @since 1.3.0
* @since 1.3.1 Added count param.
*/
return apply_filters( 'loggedin_reached_limit', $reached, $user_id, $count );
}
/**
* Custom login limit bypassing.
*
* Filter to bypass login limit based on a condition.
* You can make use of this filter if you want to bypass
* some users or roles from limit limit.
*
* @param int $user_id User ID.
*
* @since 1.0.0
*
* @return bool
*/
private function bypass( $user_id ) {
/**
* Filter hook to bypass the check.
*
* @param bool $bypass Bypassed.
* @param int $user_id User ID.
*
* @since 1.0.0
*/
return (bool) apply_filters( 'loggedin_bypass', false, $user_id );
}
/**
* Error message text if user active logins count is maximum
*
* @since 1.0.0
* @access public
*
* @return string Error message
*/
private function error_message() {
// Error message.
$message = __( 'Maximum no. of active logins found for this account. Please logout from another device to continue.', 'loggedin' );
/**
* Filter hook to change the error message.
*
* @param string $message Message.
*
* @since 1.0.0
*/
return apply_filters( 'loggedin_error_message', $message );
}
}

View File

@@ -0,0 +1 @@
<?php

Binary file not shown.

View File

@@ -0,0 +1,75 @@
msgid ""
msgstr ""
"Project-Id-Version: LoggedIn - Limit Active Logins\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-25 14:11+0000\n"
"PO-Revision-Date: 2019-09-04 11:17+0300\n"
"Language-Team: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.3\n"
"X-Loco-Version: 2.2.0; wp-5.1\n"
"Last-Translator: \n"
"Language: el\n"
#: includes/class-f-loggedin-admin.php:51
msgid "Maximum Active Logins"
msgstr "Μέγιστος Αριθμός Συνδέσεων"
#: includes/class-f-loggedin-admin.php:71
msgid "Set the maximum no. of active logins a user account can have."
msgstr ""
"Ορίστε τον μέγιστο αριθμός ενεργών συνδέσεων που μπορεί να έχει ένας "
"χρήστης."
#: includes/class-f-loggedin-admin.php:72
msgid ""
"If this limit reached, next login request will be failed and user will have "
"to logout from one device to continue."
msgstr ""
"Εάν ξεπεραστεί αυτό το όριο, η σύνδεση δε θα είναι εφικτή και ο χρήστης θα "
"πρέπει να αποσυνδεθεί από τη συσκευή του για να συνεχίσει."
#: includes/class-f-loggedin-admin.php:73
msgid "Note: "
msgstr "Σημείωση: "
#: includes/class-f-loggedin-admin.php:73
msgid "Even if the browser is closed, login session may exist."
msgstr ""
"Ακόμη και αν ο broweser είναι κλειστός, η σύνδεση μπορεί να είναι ενεργή."
#: includes/class-f-loggedin.php:117
msgid ""
"Maximum no. of active logins found for this account. Please logout from "
"another device to continue."
msgstr ""
"Ο μέγιστος αριθμός συνδέσεων έχει ξεπεραστεί για αυτόν τον λογαριασμό. "
"Παρακαλώ αποσυνδεθείτε από τις άλλες συσκευές σας για να συνεχίσετε."
#. Name of the plugin
msgid "LoggedIn - Limit Active Logins"
msgstr "LoggedIn - Περιορισμός Ενεργών Συνδέσεων"
#. Description of the plugin
msgid ""
"Light weight plugin to limit number of active logins from an account. Set "
"maximum number of concurrent logins a user can have from multiple places."
msgstr ""
"Λογισμικό για να περιορίζεται τον αριθμό ενεργών συνδέσεων για κάθε "
"λογαριασμό. Ορίστε τον μέγιστο αριθμό συνδέσεων ενός χρήστη από διαφορετικά "
"σημεία."
#. URI of the plugin
msgid "https://wordpress.org/plugins/loggedin/"
msgstr "https://wordpress.org/plugins/loggedin/"
#. Author of the plugin
msgid "Joel James"
msgstr "Τζόελ Τζέημς"
#. Author URI of the plugin
msgid "https://thefoxe.com/"
msgstr "https://thefoxe.com/"

Binary file not shown.

View File

@@ -0,0 +1,72 @@
msgid ""
msgstr ""
"Project-Id-Version: LoggedIn - Limit Active Logins\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-25 14:11+0000\n"
"PO-Revision-Date: 2019-02-25 14:22+0000\n"
"Last-Translator: Antti Koskinen <antti.koskinen@fissiomedia.fi>\n"
"Language-Team: Suomi\n"
"Language: fi\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/\n"
"X-Loco-Version: 2.2.0; wp-5.1"
#: includes/class-f-loggedin-admin.php:51
msgid "Maximum Active Logins"
msgstr "Istuntojen enimmäismäärä"
#: includes/class-f-loggedin-admin.php:71
msgid "Set the maximum no. of active logins a user account can have."
msgstr "Montako aktiivista istuntoa käyttäjällä voi olla yhtä aikaa."
#: includes/class-f-loggedin-admin.php:72
msgid ""
"If this limit reached, next login request will be failed and user will have "
"to logout from one device to continue."
msgstr ""
"Enimmäismäärän täyttyessä seuraava kirjautumisyritys epäonnistuu ja "
"käyttäjän on ensin kirjauduttava ulos joltain toiselta laitteelta."
#: includes/class-f-loggedin-admin.php:73
msgid "Note: "
msgstr "Huom:"
#: includes/class-f-loggedin-admin.php:73
msgid "Even if the browser is closed, login session may exist."
msgstr "Istunto voi jäädä aktiiviseksi vaikka nettiselain suljettaisiinkin."
#: includes/class-f-loggedin.php:117
msgid ""
"Maximum no. of active logins found for this account. Please logout from "
"another device to continue."
msgstr ""
"Kaikki aktiiviset istunnot käytössä. Ole hyvä ja kirjaudu ulos joltain "
"toiselta laitteelta jatkaaksesi."
#. Name of the plugin
msgid "LoggedIn - Limit Active Logins"
msgstr "LoggedIn - Rajoita aktiivisia istuntoja"
#. Description of the plugin
msgid ""
"Light weight plugin to limit number of active logins from an account. Set "
"maximum number of concurrent logins a user can have from multiple places."
msgstr ""
"Lisäosa, jonka avulla voit rajoittaa aktiivisten istuntojen määrää. Aseta "
"enimmäismäärä aktiivisille istunnoille, joita käyttäjällä voi olla yhtä "
"aikaa eri laitteilla tai selaimilla."
#. URI of the plugin
msgid "https://wordpress.org/plugins/loggedin/"
msgstr "https://wordpress.org/plugins/loggedin/"
#. Author of the plugin
msgid "Joel James"
msgstr "Joel James"
#. Author URI of the plugin
msgid "https://thefoxe.com/"
msgstr "https://thefoxe.com/"

View File

@@ -0,0 +1,149 @@
# Copyright (C) 2020 Joel James
# This file is distributed under the GPL-2.0+.
msgid ""
msgstr ""
"Project-Id-Version: Loggedin - Limit Active Logins 1.3.1\n"
"Report-Msgid-Bugs-To: https://duckdev.com\n"
"POT-Creation-Date: 2020-09-19 03:34:00+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Joel James <me@joelsays.com>\n"
"X-Generator: grunt-wp-i18n 1.0.3\n"
#: includes/class-loggedin-admin.php:74
#. translators: %s User name of the logging out user.
msgid "User %s forcefully logged out from all devices."
msgstr ""
#: includes/class-loggedin-admin.php:86
#. translators: %d User ID of the login user.
msgid "Invalid user ID: %d"
msgstr ""
#: includes/class-loggedin-admin.php:121
msgid "Maximum Active Logins"
msgstr ""
#: includes/class-loggedin-admin.php:130
msgid "Login Logic"
msgstr ""
#: includes/class-loggedin-admin.php:139 includes/class-loggedin-admin.php:195
msgid "Force Logout"
msgstr ""
#: includes/class-loggedin-admin.php:159
msgid "Enter the limit in number"
msgstr ""
#: includes/class-loggedin-admin.php:160
msgid "Set the maximum no. of active logins a user account can have."
msgstr ""
#: includes/class-loggedin-admin.php:161
msgid ""
"If this limit reached, next login request will be failed and user will have "
"to logout from one device to continue."
msgstr ""
#: includes/class-loggedin-admin.php:162
msgid "Note: "
msgstr ""
#: includes/class-loggedin-admin.php:162
msgid "Even if the browser is closed, login session may exist."
msgstr ""
#: includes/class-loggedin-admin.php:178
msgid "Allow"
msgstr ""
#: includes/class-loggedin-admin.php:179
msgid "Block"
msgstr ""
#: includes/class-loggedin-admin.php:180
msgid "Allow:"
msgstr ""
#: includes/class-loggedin-admin.php:180
msgid ""
"Allow new login by terminating all other old sessions when the limit is "
"reached."
msgstr ""
#: includes/class-loggedin-admin.php:181
msgid "Block:"
msgstr ""
#: includes/class-loggedin-admin.php:181
msgid ""
" Do not allow new login if the limit is reached. Users need to wait for the "
"old login sessions to expire."
msgstr ""
#: includes/class-loggedin-admin.php:194
msgid "Enter user ID"
msgstr ""
#: includes/class-loggedin-admin.php:196
msgid ""
"If you would like to force logout a user from all the devices, enter the "
"user ID."
msgstr ""
#: includes/class-loggedin-admin.php:242
#. translators: %1$s Current user's name. %2$s <strong> %3$s </strong>.
msgid ""
"Hey %1$s, I noticed you've been using %2$sLoggedin%3$s plugin for more than "
"1 week thats awesome! Could you please do me a BIG favor and give it a "
"5-star rating on WordPress? Just to help us spread the word and boost our "
"motivation."
msgstr ""
#: includes/class-loggedin-admin.php:243
msgid "there"
msgstr ""
#: includes/class-loggedin-admin.php:251
msgid "Ok, you deserve it"
msgstr ""
#: includes/class-loggedin-admin.php:256
msgid "Nope, maybe later"
msgstr ""
#: includes/class-loggedin-admin.php:261
msgid "I already did"
msgstr ""
#: includes/class-loggedin.php:186
msgid ""
"Maximum no. of active logins found for this account. Please logout from "
"another device to continue."
msgstr ""
#. Plugin Name of the plugin/theme
msgid "Loggedin - Limit Active Logins"
msgstr ""
#. Plugin URI of the plugin/theme
msgid "https://duckdev.com/products/loggedin-limit-active-logins/"
msgstr ""
#. Description of the plugin/theme
msgid ""
"Light weight plugin to limit number of active logins from an account. Set "
"maximum number of concurrent logins a user can have from multiple places."
msgstr ""
#. Author of the plugin/theme
msgid "Joel James"
msgstr ""
#. Author URI of the plugin/theme
msgid "https://duckdev.com/"
msgstr ""

View File

@@ -0,0 +1,78 @@
<?php
/**
* Main plugin header.
*
* @package LoggedIn
*
* Plugin Name: Loggedin - Limit Active Logins
* Plugin URI: https://duckdev.com/products/loggedin-limit-active-logins/
* Description: Light weight plugin to limit number of active logins from an account. Set maximum number of concurrent logins a user can have from multiple places.
* Version: 1.3.2
* Author: Joel James
* Author URI: https://duckdev.com/
* Donate link: https://paypal.me/JoelCJ
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: loggedin
* Domain Path: /languages
*
* LoggedIn is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* LoggedIn is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LoggedIn. If not, see <http://www.gnu.org/licenses/>.
*/
// If this file is called directly, abort.
defined( 'WPINC' ) || die( 'Well, get lost.' );
// Make sure loggedin is not already defined.
if ( ! function_exists( 'loggedin_init' ) ) {
/**
* Main instance of plugin.
*
* Returns the main instance of Beehive to prevent the need to use globals
* and to maintain a single copy of the plugin object.
* You can simply call beehive_analytics() to access the object.
*
* @since 1.3.0
*
* @return void
*/
function loggedin_init() {
// Load text domain.
load_plugin_textdomain(
'loggedin',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages/'
);
// Load required files.
require dirname( __FILE__ ) . '/includes/class-loggedin.php';
require dirname( __FILE__ ) . '/includes/class-loggedin-admin.php';
// Load core class.
new Loggedin();
// Load admin class.
new Loggedin_Admin();
/**
* Action hook to execute after LoggedIn plugin init.
*
* Use this hook to init addons.
*
* @since 1.3.1
*/
do_action( 'loggedin_init' );
}
}
// Init the plugin.
add_action( 'plugins_loaded', 'loggedin_init' );

View File

@@ -0,0 +1,210 @@
=== Loggedin - Limit Active Logins ===
Contributors: joelcj91,duckdev
Tags: login, logout, limit active logins, login limit, concurrent logins
Donate link: https://paypal.me/JoelCJ
Requires at least: 4.0
Tested up to: 6.6
Stable tag: 1.3.2
Requires PHP: 5.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Light weight plugin to limit number of active logins from an account. Set maximum number of concurrent logins a user can have from multiple places.
== Description ==
By default in WordPress users can login using one account from **unlimited** devices/browsers at a time. This is not good for everyone, seriously! With this plugin you can easily set a limit for no. of active logins a user can have.
> #### Loggedin 🔒 Features and Advantages
>
> - **Set maximum no. of active logins for a user**.<br />
> - **Block new logins when the login limit is reached.**<br />
> - **Allow new logins while logging out from other devices when the limit is reached.**<br />
> - **Force logout users from admin.**<br />
> - Prevent users from sharing their account.<br />
> - Useful for membership sites (for others too).<br />
> - No complex settings. Just one optional field to set the limit.<br />
> - Super Light weight.<br />
> - Filter to bypass login limit for certain users or roles.<br />
> - Completely free to use with lifetime updates.<br />
> - Follows best WordPress coding standards.<br />
>
> [Installation](https://wordpress.org/plugins/loggedin/installation/) | [Support](http://wordpress.org/support/plugin/loggedin/) | [Screenshots](https://wordpress.org/plugins/loggedin/screenshots/)
Please contribute to the plugin development in [GitHub](https://github.com/joel-james/LoggedIn).
**🔐 Important Notice**
Even if the user is closing the browser without logging out, their login session exists for period of time. So this will also considered as an active login.
== Installation ==
= Installing the plugin - Simple =
1. In your WordPress admin panel, go to *Plugins > New Plugin*, search for **LoggedIn** and click "*Install now*"
2. Alternatively, download the plugin and upload the contents of `loggedin.zip` to your plugins directory, which usually is `/wp-content/plugins/`.
3. Activate the plugin
4. Go to General tab under WordPress Settings menu.
5. Find the "Maximum Active Logins" option and select the maximum number of active logins for a user account.
= Missing something? =
If you would like to have an additional feature for this plugin, [let me know](https://duckdev.com/support/)
== Frequently Asked Questions ==
= How can I set the limit, and where? 🤔 =
This plugin does not have a seperate settings page. But we have one configural settings to let you set the login limit.
1. Go to `Settings` page in admin dashboard.
2. Scroll down to see the section `🔐 Loggedin`.
3. Set the maximum number of active logins a user can have in `Maximum Active Logins` option.
= Can I somehow allow new logins when the limit is reached? 🤔 =
You can forcefully logout the user from other devices and allow new login.
1. Go to `Settings` page in admin dashboard.
2. Scroll down to see the section `🔐 Loggedin`.
3. Select the `Login Logic` as `Allow`.
= Can I block the new logins when the limit is reached? 🤔 =
You block the new logins when the user is logged in from maximum no. of devices according to the limit you set.
1. Go to `Settings` page in admin dashboard.
2. Scroll down to see the section `🔐 Loggedin`.
3. Select the `Login Logic` as `Block`.
4. Now user will have to wait for the other login sessions to expire before login from new device.
= How long a login session exist? How long the user needs to wait for new login? 🤔 =
That depends. If the “Remember Me” box is checked while login, WordPress will keep the user logged in for 14 days by default. If “Remember Me” is not checked, 2 days will be the active login session time.
You can change that period using, auth_cookie_expiration filter.
<pre lang="php">
function loggedin_auth_cookie_expiration( $expire ) {
// Allow for a month.
return MONTH_IN_SECONDS;
}
add_filter( 'auth_cookie_expiration', 'loggedin_auth_cookie_expiration' );
</pre>
= How can I forcefully logout a user from all devices? 🤔 =
You can forcefully logout a user from all the devices he has logged into. Get his WordPress user ID and,
1. Go to `Settings` page in admin dashboard.
2. Scroll down to see the section `🔐 Loggedin`.
3. Enter user ID of the user you would like to logout.
4. Click `Force Logout`.
= Can I bypass this limit for certain users or roles? 🤔 =
Yes, of course. But this time you are going to add few lines of code. Don't worry. Just copy+paste this code in your theme's `functions.php` file or in custom plugin:
<pre lang="php">
function loggedin_bypass_users( $bypass, $user_id ) {
// Enter the user IDs to bypass.
$allowed_users = array( 1, 2, 3, 4, 5 );
return in_array( $user_id, $allowed_users );
}
add_filter( 'loggedin_bypass', 'loggedin_bypass_users', 10, 2 );
</pre>
Or if you want to bypass this for certain roles:
<pre lang="php">
function loggedin_bypass_roles( $prevent, $user_id ) {
// Array of roles to bypass.
$allowed_roles = array( 'administrator', 'editor' );
$user = get_user_by( 'id', $user_id );
$roles = ! empty( $user->roles ) ? $user->roles : array();
return ! empty( array_intersect( $roles, $whitelist ) );
}
add_filter( 'loggedin_bypass', 'loggedin_bypass_roles', 10, 2 );
</pre>
== Other Notes ==
= 🐛 Bug Reports =
Bug reports are always welcome - [report here](https://duckdev.com/support/).
== Screenshots ==
1. **Settings** - Set maximum no. of active logins for a user account.
== Changelog ==
= 1.3.2 (01/10/2024) =
**🐛 Bug Fixes**
* Security fixes.
= 1.3.1 (19/09/2020) =
**👌 Improvements**
* Support ajax logins - Thanks [Carlos Faria](https://github.com/cfaria).
= 1.3.0 (28/08/2020) =
**👌 Improvements**
* Improved "Allow" logic to check only after password check.
= 1.2.0 (07/06/2019) =
**📦 New**
* Added ability to choose login logic.
= 1.1.0 (06/06/2019) =
**📦 New**
* Added ability to force logout users.
* Added cleanup on plugin uninstall.
* Added review notice.
**👌 Improvements**
* Code improvement
= 1.0.1 (02/07/2016) =
**🐛 Bug Fixes**
* Fixing misspelled variable.
= 1.0.0 (16/06/2016) =
**📦 New**
* Initial version release.
== Upgrade Notice ==
= 1.3.2 (01/10/2024) =
**🐛 Bug Fixes**
* Security fixes.

View File

@@ -0,0 +1,31 @@
<?php
/**
* Fired when the plugin is uninstalled.
*
* @link https://duckdev.com/products/loggedin-limit-active-logins/
* @license http://www.gnu.org/licenses/ GNU General Public License
* @category Core
* @package Loggedin
* @subpackage Uninstall
* @author Joel James <me@joelsays.com>
*/
// If uninstall not called from WordPress, then exit.
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
// Delete all options added by the plugin.
delete_option( 'loggedin_maximum' );
delete_option( 'loggedin_rating_notice' );
global $wpdb;
// Delete all meta values added by the plugin.
// phpcs:ignore
$wpdb->delete(
$wpdb->usermeta,
array(
// Review notice meta.
// phpcs:ignore
'meta_key' => 'loggedin_rating_notice_dismissed',
)
);