Plugin Directory

Changeset 3352346


Ignore:
Timestamp:
08/28/2025 11:41:22 PM (7 months ago)
Author:
dangoweb
Message:

Version 1.4

Location:
block-user-account
Files:
13 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • block-user-account/trunk/block-user-account.php

    r2790779 r3352346  
    44 * Plugin URI: https://dangoweb.ir/product/buacc-wordpress-user-block-plugin/
    55 * Description: Block Users Accounts On your Site.
    6  * Version: 1.3.1
     6 * Version: 1.4
    77 * Author: DangoWeb
    88 * Author URI: https://dangoweb.ir
     
    2929    $current_user_id = get_current_user_id();
    3030    if ($user_id != $current_user_id):
    31         wp_enqueue_style('user_status_style', BUA_CSS_URL . '/style.css');
    32         if (current_user_can('edit_users')):
    33             ?>
     31        if (current_user_can('edit_users')): ?>
    3432            <table class="form-table" id="block_user">
    3533                <tr>
     
    3836                    </th>
    3937                    <td>
    40                         <label class="tgl">
    41                             <input type="checkbox" name="user_status" value="deactive"
     38                        <label class="bua-toggle-switch">
     39                            <input type="checkbox" class="toggle-input" name="user_status" value="deactive"
    4240                                   id="user_status" <?php checked(get_user_meta($user_id, 'user_status', true), 'deactive'); ?>>
    43                             <span data-off="<?php _e("Enabled", 'block-user-account'); ?>"
    44                                   data-on="<?php _e("Disabled", 'block-user-account'); ?>"></span>
     41                            <span class="bua-toggle-slider"></span>
    4542                        </label>
    46                         <span class="description"><?php _e("Green: Account is Active. / Red: Account is Blocked.", 'block-user-account'); ?></span>
     43                        <p class="description"><?php _e("Green: Account is Active. / Red: Account is Blocked.", 'block-user-account'); ?></p>
    4744                    </td>
    4845                </tr>
     
    5956                    </td>
    6057                </tr>
    61                 <script>
    62                     jQuery(function ($) {
    63                         var checkbox = document.querySelector("#user_status");
    64                         var input = document.querySelector("#user_status_message");
    65                         var toogleInput = function (e) {
    66                             input.disabled = !e.target.checked;
    67                         };
    68                         toogleInput({target: checkbox});
    69                         checkbox.addEventListener("change", toogleInput);
    70                     });
    71                 </script>
    7258            </table>
    7359        <?php
     
    7662
    7763    return;
    78 }
    79 
    80 //Session
    81 function bua_destroy_user_session($user_id)
    82 {
    83     $sessions = WP_Session_Tokens::get_instance($user_id);
    84     $sessions->destroy_all();
    8564}
    8665
     
    10180            delete_user_meta($user_id, 'user_status_message');
    10281        endif;
    103         bua_destroy_user_session($user_id);
     82        $sessions = WP_Session_Tokens::get_instance($user_id);
     83        $sessions->destroy_all();
    10484    endif;
    10585
    106     return;
     86
    10787}
    10888
    10989//Bulk Actions
    110 add_filter('bulk_actions-users', 'bua_bulk_actions');
    111 function bua_bulk_actions($bulk_actions)
     90add_filter('bulk_actions-users', 'bua_user_bulk_actions');
     91function bua_user_bulk_actions($bulk_actions)
    11292{
    11393    $bulk_actions['bua_block_users'] = __('Block Users', 'block-user-account');
     
    11696}
    11797
    118 add_filter('handle_bulk_actions-users', 'bua_bulk_actions_handle', 10, 3);
    119 function bua_bulk_actions_handle($redirect_to, $action, $user_ids)
     98add_filter('handle_bulk_actions-users', 'bua_user_bulk_actions_handle', 10, 3);
     99function bua_user_bulk_actions_handle($redirect_to, $action, $user_ids)
    120100{
    121101    $current_user_id = get_current_user_id();
     102
     103    if (!current_user_can('edit_users')) {
     104        return $redirect_to;
     105    }
     106
    122107    if ($action == 'bua_block_users') {
    123108        foreach ($user_ids as $user_id) {
    124             if (current_user_can('edit_users')) {
    125                 if ($user_id != $current_user_id) {
    126                     update_user_meta($user_id, 'user_status', 'deactive');
    127                     bua_destroy_user_session($user_id);
    128                 }
     109            if ($user_id != $current_user_id) {
     110                update_user_meta($user_id, 'user_status', 'deactive');
     111                $sessions = WP_Session_Tokens::get_instance($user_id);
     112                $sessions->destroy_all();
    129113            }
    130             if (!current_user_can('edit_users')) {
    131                 wp_die(__('Sorry, you are not allowed to edit this user.'), 403);
    132             }
    133 
    134114        }
    135         $redirect_to = add_query_arg('bua_block_users', count($user_ids), $redirect_to);
    136 //        $redirect_to = remove_query_arg('bua_block_users', $redirect_to);
    137115    } elseif ($action == 'bua_active_users') {
    138116        foreach ($user_ids as $user_id) {
    139             if (current_user_can('edit_users')) {
    140                 delete_user_meta($user_id, 'user_status');
    141             }
    142             if (!current_user_can('edit_users')) {
    143                 wp_die(__('Sorry, you are not allowed to edit this user.'), 403);
    144             }
     117            delete_user_meta($user_id, 'user_status');
    145118        }
    146         $redirect_to = add_query_arg('bua_active_users', count($user_ids), $redirect_to);
    147119    }
     120
    148121    return $redirect_to;
    149 }
    150 
    151 add_action('admin_notices', 'bua_bulk_action_notice');
    152 function bua_bulk_action_notice()
    153 {
    154     if (!empty($_REQUEST['bua_block_users']) && isset($_REQUEST['bua_block_users'])) {
    155         $changes = intval($_REQUEST['bua_block_users']);
    156         printf('<div id="message" class="updated notice is-dismissable"><p>' . __('%d Users were Blocked.', 'block-user-account') . '</p></div>', $changes);
    157     }
    158     if (!empty($_REQUEST['bua_active_users']) && isset($_REQUEST['bua_active_users'])) {
    159         $changes = intval($_REQUEST['bua_active_users']);
    160         printf('<div id="message" class="updated notice is-dismissable"><p>' . __('%d Users Activated.', 'block-user-account') . '</p></div>', $changes);
    161     }
    162122}
    163123
     
    166126function bua_user_status_column($column)
    167127{
    168     $column['user_status'] = __('User Status', 'block-user-account');
    169     $column['user_status_reasen'] = __('Blocked Reason', 'block-user-account');
     128    $column['bua_user_status'] = __('User Status', 'block-user-account');
     129    $column['bua_user_status_reasen'] = __('Blocked Reason', 'block-user-account');
    170130    return $column;
    171131}
     
    174134function bua_show_user_status($value, $column, $userid)
    175135{
    176     wp_enqueue_style('user_status_style', BUA_CSS_URL . '/style.css');
    177136    $active = __('Active', 'block-user-account');
    178137    $blocked = __('Blocked', 'block-user-account');
     
    180139    $user_status_message = get_user_meta($userid, 'user_status_message', true);
    181140
    182     if ('user_status' == $column) {
     141    if ('bua_user_status' == $column) {
    183142        if ($user_status === 'deactive') {
    184             return "<span class='user-status-deactive'>" . $blocked . "</span>";
     143            return '<span class="user-status-deactive"><svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px"><path d="M480-80q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Zm-80 160h160q17 0 28.5-11.5T600-360v-120q0-17-11.5-28.5T560-520v-40q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560v40q-17 0-28.5 11.5T360-480v120q0 17 11.5 28.5T400-320Zm40-200v-40q0-17 11.5-28.5T480-600q17 0 28.5 11.5T520-560v40h-80Z"/></svg>' . $blocked . '</span>';
    185144        } else {
    186             return "<span class='user-status-active'>" . $active . "</span>";
     145            return '<span class="user-status-active"><svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px"><path d="m438-338 226-226-57-57-169 169-84-84-57 57 141 141Zm42 258q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z"/></svg>' . $active . '</span>';
    187146        }
    188147    }
    189     if ('user_status_reasen' == $column) {
     148    if ('bua_user_status_reasen' == $column) {
    190149        if ($user_status == 'deactive') {
    191150            return "<div>" . $user_status_message . "</div>";
     
    200159function bua_login_authenticate($user, $username)
    201160{
    202     if (is_email($username)):
     161    $userinfo = get_user_by('login', $username);
     162    if (!$userinfo && is_email($username)) {
    203163        $userinfo = get_user_by('email', $username);
    204     else:
    205         $userinfo = get_user_by('login', $username);
    206     endif;
    207 
     164    }
    208165    if (!$userinfo) {
    209166        return $user;
    210167    } elseif (get_user_meta($userinfo->ID, 'user_status', true) === 'deactive') {
    211168        $user_message = get_user_meta($userinfo->ID, 'user_status_message', true);
    212         $default_message = __('Your account is disabled.', 'block-user-account');
     169        $default_message = __('Your account has been temporarily disabled. Please contact the administrator.', 'block-user-account');
    213170        $message = !empty($user_message) ? $user_message : $default_message;
    214171        $error = new WP_Error();
     
    220177    return $user;
    221178}
     179
     180add_action('admin_enqueue_scripts', function ($hook) {
     181    if ($hook == 'user-edit.php' || $hook == 'profile.php' || $hook == 'users.php') {
     182        wp_enqueue_style('bua_admin_style', BUA_CSS_URL . '/style.css');
     183    }
     184});
  • block-user-account/trunk/css/style.css

    r2278828 r3352346  
    11.column-user_status,
    22.user_status_reasen,
    3 .column-user_status_reasen{
    4     text-align: center!important;
    5     vertical-align: middle!important;
     3.column-user_status_reasen {
     4    text-align: center !important;
     5    vertical-align: middle !important;
    66}
    7 .user-status-active{
    8     background-color: #79d122;
     7
     8.user-status-deactive,
     9.user-status-active {
     10    background-color: #2ecc71;
    911    color: #FFF;
    10     padding:3px 10px;
     12    fill: #FFF;
     13    padding: 3px 10px;
    1114    border-radius: 3px;
     15    display: inline-flex;
     16    align-items: center;
     17    justify-content: center;
     18    min-width: 65px;
    1219}
    13 .user-status-active:hover{
    14     background-color: #62af1e;
     20
     21.user-status-deactive {
     22    background-color: #e74c3c;
    1523}
    16 .user-status-deactive{
    17     background-color: #c63d3d;
    18     color: #FFF;
    19     padding:3px 10px;
    20     border-radius: 3px;
     24
     25.bua-toggle-switch .toggle-input {
     26    display: none;
    2127}
    22 .user-status-deactive:hover{
    23     background-color: #b13838;
     28
     29.bua-toggle-switch {
     30    position: relative;
     31    display: inline-block;
     32    width: 60px;
     33    height: 25px;
    2434}
    25 .tgl {
    26   position: relative;
    27   outline: 0;
    28   display: inline-block;
    29   cursor: pointer;
    30   user-select: none;
    31   margin: 0 0 5px 0;
     35
     36.bua-toggle-slider {
     37    position: absolute;
     38    cursor: pointer;
     39    top: 0;
     40    left: 0;
     41    right: 0;
     42    bottom: 0;
     43    background-color: #2ecc71;
     44    transition: 0.4s;
     45    border-radius: 34px;
    3246}
    33 .tgl,
    34 .tgl:after,
    35 .tgl:before,
    36 .tgl *,
    37 .tgl *:after,
    38 .tgl *:before,
    39 .tgl + .tgl-btn {
    40   box-sizing: border-box;
     47
     48.bua-toggle-slider:before {
     49    position: absolute;
     50    content: "";
     51    height: 20px;
     52    width: 20px;
     53    left: 5px;
     54    bottom: 3px;
     55    background-color: white;
     56    transition: 0.4s;
     57    border-radius: 50%;
    4158}
    42 .tgl::selection,
    43 .tgl:after::selection,
    44 .tgl:before::selection,
    45 .tgl *::selection,
    46 .tgl *:after::selection,
    47 .tgl *:before::selection,
    48 .tgl + .tgl-btn::selection {
    49   background: none;
     59
     60.toggle-input:checked + .bua-toggle-slider {
     61    background-color: #e74c3c;
    5062}
    51 .tgl span {
    52   position: relative;
    53   display: block;
    54   height: 1.8em;
    55   line-height: 1.2em;
    56   overflow: hidden;
    57   font-weight: normal;
    58   text-align: center;
    59   border-radius: 2em;
    60   padding: 0.2em 1em;
    61   border: 1px solid #fafafa;
    62   box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.2), 0 2px 0 rgba(255, 255, 255, 0.7);
    63   transition: color 0.3s ease, padding 0.3s ease-in-out, background 0.3s ease-in-out;
     63
     64.toggle-input:checked + .bua-toggle-slider:before {
     65    transform: translateX(30px);
    6466}
    65 .tgl span:before {
    66   position: relative;
    67   display: block;
    68   line-height: 1.3em;
    69   padding: 0 0.2em;
    70   font-size: 1em;
    71 }
    72 .tgl span:after {
    73   position: absolute;
    74   display: block;
    75   content: '';
    76   border-radius: 2em;
    77   width: 1.3em;
    78   height: 1.3em;
    79   margin-left: -1.45em;
    80   top: 0.2em;
    81   background: #FFFFFF;
    82   transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 0.97), background 0.3s ease-in-out;
    83 }
    84 .tgl input[type="checkbox"] {
    85   display: none !important;
    86 }
    87 .tgl input[type="checkbox"]:not(:checked) + span {
    88   background: #86d993;
    89   color: #FFFFFF;
    90   padding-left: 1.6em;
    91   padding-right: 0.4em;
    92 }
    93 .tgl input[type="checkbox"]:not(:checked) + span:before {
    94   content: attr(data-off);
    95   color: #FFFFFF;
    96 }
    97 .tgl input[type="checkbox"]:not(:checked) + span:after {
    98   background: #FFFFFF;
    99   left: 1.6em;
    100 }
    101 .tgl input[type="checkbox"]:checked + span {
    102   background: #de474e;
    103   color: #FFFFFF;
    104   padding-left: 0.4em;
    105   padding-right: 1.6em;
    106 }
    107 .tgl input[type="checkbox"]:checked + span:before {
    108   content: attr(data-on);
    109 }
    110 .tgl input[type="checkbox"]:checked + span:after {
    111   background: #FFFFFF;
    112   left: 100%;
    113 }
  • block-user-account/trunk/languages/block-user-account-fa_IR.po

    r2691596 r3352346  
    22msgstr ""
    33"Project-Id-Version: Block User Account\n"
    4 "POT-Creation-Date: 2022-03-09 20:39+0330\n"
    5 "PO-Revision-Date: 2022-03-09 20:39+0330\n"
     4"POT-Creation-Date: 2025-08-29 02:30+0330\n"
     5"PO-Revision-Date: 2025-08-29 02:30+0330\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212"Plural-Forms: nplurals=1; plural=0;\n"
    13 "X-Generator: Poedit 2.4.2\n"
     13"X-Generator: Poedit 3.7\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
    1616"X-Poedit-WPHeader: block-user-account.php\n"
    1717"X-Poedit-SourceCharset: UTF-8\n"
    18 "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
    19 "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
    20 "_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
     18"X-Poedit-KeywordsList: "
     19"__;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
    2120"X-Poedit-SearchPath-0: .\n"
    2221"X-Poedit-SearchPathExcluded-0: *.js\n"
    2322
    24 #: block-user-account.php:37
     23#: block-user-account.php:35
    2524msgid "User Account Status"
    2625msgstr "وضعیت حساب کاربر"
    2726
    2827#: block-user-account.php:43
    29 msgid "Enabled"
    30 msgstr "فعال"
    31 
    32 #: block-user-account.php:44
    33 msgid "Disabled"
    34 msgstr "غیرفعال"
    35 
    36 #: block-user-account.php:46
    3728msgid "Green: Account is Active. / Red: Account is Blocked."
    3829msgstr "سبز: حساب فعال است. / قرمز: حساب مسدود است."
    3930
    40 #: block-user-account.php:52
     31#: block-user-account.php:49
    4132msgid "Why the user is blocked Message"
    4233msgstr "پیام چرا کاربر مسدود شده است"
    4334
    44 #: block-user-account.php:113
     35#: block-user-account.php:93
    4536msgid "Block Users"
    4637msgstr "مسدودسازی کاربر"
    4738
    48 #: block-user-account.php:114
     39#: block-user-account.php:94
    4940msgid "Active Users"
    5041msgstr "فعال کردن کاربر"
    5142
    52 #: block-user-account.php:131 block-user-account.php:143
    53 msgid "Sorry, you are not allowed to edit this user."
    54 msgstr "متاسفیم، شما مجاز به ویرایش این کاربر نیستید."
    55 
    56 #: block-user-account.php:156
    57 #, php-format
    58 msgid "%d Users were Blocked."
    59 msgstr "%d کاربر مسدود شدند."
    60 
    61 #: block-user-account.php:160
    62 #, php-format
    63 msgid "%d Users Activated."
    64 msgstr "%d کاربر فعال شدند."
    65 
    66 #: block-user-account.php:168
     43#: block-user-account.php:128
    6744msgid "User Status"
    6845msgstr "وضعیت کاربر"
    6946
    70 #: block-user-account.php:169
     47#: block-user-account.php:129
    7148msgid "Blocked Reason"
    7249msgstr "دلیل مسدودی"
    7350
    74 #: block-user-account.php:177
     51#: block-user-account.php:136
    7552msgid "Active"
    7653msgstr "فعال"
    7754
    78 #: block-user-account.php:178
     55#: block-user-account.php:137
    7956msgid "Blocked"
    8057msgstr "مسدود"
    8158
    82 #: block-user-account.php:212
    83 msgid "Your account is disabled."
    84 msgstr "حساب کاربری شما غیرفعال شده است."
     59#: block-user-account.php:169
     60msgid ""
     61"Your account has been temporarily disabled. Please contact the administrator."
     62msgstr "حساب کاربری شما مسدود شده است. لطفا با مدیریت ارتباط برقرار کنید."
    8563
    8664#. Plugin Name of the plugin/theme
     
    8967
    9068#. Plugin URI of the plugin/theme
    91 msgid "https://zoroufchi.ir/block-user-account-wordpress-plugin"
    92 msgstr "https://zoroufchi.ir/block-user-account-wordpress-plugin"
     69msgid "https://dangoweb.ir/product/buacc-wordpress-user-block-plugin/"
     70msgstr "https://dangoweb.ir/product/buacc-wordpress-user-block-plugin/"
    9371
    9472#. Description of the plugin/theme
     
    9775
    9876#. Author of the plugin/theme
    99 msgid "Mahmoud Zoroufchi"
    100 msgstr "محمود ظروفچی"
     77msgid "DangoWeb"
     78msgstr "دانگو وب"
    10179
    10280#. Author URI of the plugin/theme
    103 msgid "https://zoroufchi.ir"
    104 msgstr "https://zoroufchi.ir"
     81msgid "https://dangoweb.ir"
     82msgstr "https://dangoweb.ir"
     83
     84#~ msgid "Enabled"
     85#~ msgstr "فعال"
     86
     87#~ msgid "Disabled"
     88#~ msgstr "غیرفعال"
     89
     90#~ msgid "Sorry, you are not allowed to edit this user."
     91#~ msgstr "متاسفیم، شما مجاز به ویرایش این کاربر نیستید."
     92
     93#, php-format
     94#~ msgid "%d Users were Blocked."
     95#~ msgstr "%d کاربر مسدود شدند."
     96
     97#, php-format
     98#~ msgid "%d Users Activated."
     99#~ msgstr "%d کاربر فعال شدند."
     100
     101#~ msgid "Your account is disabled."
     102#~ msgstr "حساب کاربری شما غیرفعال شده است."
     103
     104#~ msgid "Mahmoud Zoroufchi"
     105#~ msgstr "محمود ظروفچی"
     106
     107#~ msgid "https://zoroufchi.ir"
     108#~ msgstr "https://zoroufchi.ir"
    105109
    106110#~ msgid ""
     
    114118#~ msgid "This Plugin can Block the User Account."
    115119#~ msgstr "مسدودساز حساب کاربری"
    116 
    117 #~ msgid "https://dangoweb.ir/"
    118 #~ msgstr "https://dangoweb.ir/"
  • block-user-account/trunk/readme.txt

    r3168829 r3352346  
    33Donate link: https://zarinp.al/dangoweb.ir
    44Tags: block user, disable account, block account
    5 Requires at least: 6.0
    6 Tested up to: 6.7
    7 Stable tag: 1.3.1
     5Requires at least: 6.5
     6Tested up to: 6.8
     7Stable tag: 1.4
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    3131
    3232== Changelog ==
     33= 1.4.0 =
     34* Improved compatibility with WordPress 6.8
     35
    3336= 1.3.0 =
    3437* ADD Bulk Actions
Note: See TracChangeset for help on using the changeset viewer.