Plugin Directory

Changeset 1968416


Ignore:
Timestamp:
11/04/2018 02:37:00 AM (7 years ago)
Author:
maratbn
Message:

Copied over the latest development code into this repo. The official repo is at: https://github.com/maratbn/LoginRequirePress

Location:
loginrequirepress/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • loginrequirepress/trunk/LICENSE

    r1478400 r1968416  
    2929  http://www.maratbn.com/projects/login-require-press
    3030
    31   Copyright (C) 2015-2016  Marat Nepomnyashy  http://maratbn.com  maratbn@gmail
     31  Copyright (C) 2015-2018  Marat Nepomnyashy  http://maratbn.com  maratbn@gmail
    3232
    33   Version:        1.3.0-development_unreleased
     33  Version:        1.4.0-development_unreleased
    3434
    3535  Module:         loginrequirepress/LICENSE
  • loginrequirepress/trunk/LoginRequirePress.php

    r1478400 r1968416  
    99  Author URI: http://www.maratbn.com
    1010  License: GPL3
    11   Version: 1.3.0-development_unreleased
     11  Version: 1.4.0-development_unreleased
    1212  Text Domain: domain-plugin-LoginRequirePress
    1313*/
     
    4444  http://www.maratbn.com/projects/login-require-press
    4545
    46   Copyright (C) 2015-2016  Marat Nepomnyashy  http://maratbn.com  maratbn@gmail
    47 
    48   Version:        1.3.0-development_unreleased
     46  Copyright (C) 2015-2018  Marat Nepomnyashy  http://maratbn.com  maratbn@gmail
     47
     48  Version:        1.4.0-development_unreleased
    4949
    5050  Module:         LoginRequirePress.php
     
    7272    namespace plugin_LoginRequirePress;
    7373
    74 
    75     const PHP_VERSION_MIN_SUPPORTED = '5.4';
     74    const DOMAIN_PLUGIN                 = 'domain-plugin-LoginRequirePress';
     75    const PHP_VERSION_MIN_SUPPORTED     = '5.4';
    7676
    7777    const LOCK_                         = 'lock_';
     
    105105    function action_add_meta_boxes() {
    106106        add_meta_box('plugin_LoginRequirePress_require_login',
    107                      __('Login Require Press', 'domain-plugin-LoginRequirePress'),
     107                     __('Login Require Press', DOMAIN_PLUGIN),
    108108                     '\\plugin_LoginRequirePress\\callbackMetaBox',
    109109                     null);
     
    111111
    112112    function action_admin_menu() {
    113         \add_options_page(\__('Login Require Press Settings', 'domain-plugin-LoginRequirePress'),
    114                           \__('Login Require Press', 'domain-plugin-LoginRequirePress'),
     113        \add_options_page(\__('Login Require Press Settings', DOMAIN_PLUGIN),
     114                          \__('Login Require Press', DOMAIN_PLUGIN),
    115115                          'manage_options',
    116116                          'plugin_LoginRequirePress_settings',
     
    122122        if (!\current_user_can('manage_options')) {
    123123            \wp_die(\__('Insufficient user permissions to modify options.',
    124                         'domain-plugin-LoginRequirePress'));
     124                        DOMAIN_PLUGIN));
    125125        }
    126126
     
    199199
    200200    ?><p><?=\__('Login protection:',
    201                 'domain-plugin-LoginRequirePress')?><?php
    202       ?> <strong><?=$flagLR ? \__('Enabled', 'domain-plugin-LoginRequirePress')
    203                             : \__('Disabled','domain-plugin-LoginRequirePress')?></strong></p><?php
     201                DOMAIN_PLUGIN)?><?php
     202      ?> <strong><?=$flagLR ? \__('Enabled', DOMAIN_PLUGIN)
     203                            : \__('Disabled',DOMAIN_PLUGIN)?></strong></p><?php
    204204
    205205    ?><input type='hidden' name='<?=LOGIN_REQUIRE_PRESS__META?>' value='present'><?php
     
    207207      ?><input type='checkbox' name='<?=LOGIN_REQUIRE_PRESS__LOCK?>'<?php
    208208              ?><?=$flagLR ? 'checked' : "" ?>><?php
    209           ?><?=\__('Require login', 'domain-plugin-LoginRequirePress')?><?php
     209          ?><?=\__('Require login', DOMAIN_PLUGIN)?><?php
    210210    ?></label><?php
     211    ?><p><i><?php
     212      ?><?=\__('Any changes will not persist until this post is updated via the \'<b>Publish</b>\' box.',
     213               DOMAIN_PLUGIN)?><?php
     214    ?></i></p><?php
    211215    }
    212216
     
    214218        \array_push($arrLinks,
    215219                    '<a href=\'' . getUrlSettings() . '\'>'
    216                                    . \__('Settings', 'domain-plugin-LoginRequirePress') . '</a>');
     220                                   . \__('Settings', DOMAIN_PLUGIN) . '</a>');
    217221        return $arrLinks;
    218222    }
     
    223227        //  page listings when the user is not logged in.
    224228
    225         //  Busting out if the current query is not for a feed and not for a search result when
    226         //  the user is not logged in:
    227         $flagIsSearchNotLoggedIn = \is_search() && !\is_user_logged_in();
    228         if (!(\is_feed() || $flagIsSearchNotLoggedIn)) return $arrPosts;
    229 
     229        //  Busting out if the user is already logged in:
     230        if (\is_user_logged_in()) {
     231            return $arrPosts;
     232        }
     233
     234        $flagIsFeed = \is_feed();
    230235        $arrPostsFiltered = [];
    231236
    232237        foreach ($arrPosts as $post) {
    233238            if (isLoginRequiredForPost($post)) {
    234                 if ($flagIsSearchNotLoggedIn) {
    235                     $post->post_content = \__('[Post content protected by Login Require Press.  Login to see the content.]',
    236                                               'domain-plugin-LoginRequirePress');
    237                     $post->post_title = \__('[Post title protected by Login Require Press.  Login to see the title.]',
    238                                             'domain-plugin-LoginRequirePress');
    239                 } else {
     239                if ($flagIsFeed) {
     240                    //  Completely filter login-protected posts from feeds.
    240241                    continue;
    241242                }
     243
     244                $post->post_content = \__('[Post content protected by Login Require Press.  Login to see the content.]',
     245                                          DOMAIN_PLUGIN);
     246                $post->post_excerpt = \__('[Post excerpt protected by Login Require Press.  Login to see the excerpt.]',
     247                                          DOMAIN_PLUGIN);
     248                $post->post_title = \__('[Post title protected by Login Require Press.  Login to see the title.]',
     249                                        DOMAIN_PLUGIN);
    242250            }
    243251
     
    262270            \wp_die(
    263271                \sprintf(\__('Login Require Press plugin cannot be activated because the currently active PHP version on this server is %s < %s and not supported.  PHP version >= %s is required.',
    264                              'domain-plugin-LoginRequirePress'),
     272                             DOMAIN_PLUGIN),
    265273                         \PHP_VERSION,
    266274                         PHP_VERSION_MIN_SUPPORTED,
     
    273281        if (!\current_user_can('manage_options' ))  {
    274282            \wp_die(\__('You do not have sufficient permissions to access this page.',
    275                         'domain-plugin-LoginRequirePress'));
     283                        DOMAIN_PLUGIN));
    276284        }
    277285
     
    280288                ?><hr><?php
    281289                ?><h3><?php
    282                   ?><?=\__($strName, 'domain-plugin-LoginRequirePress')?><?php
     290                  ?><?=\__($strName, DOMAIN_PLUGIN)?><?php
    283291                ?></h3><?php
    284292                ?><i><?php
    285                   ?><?=\__($strDesc, 'domain-plugin-LoginRequirePress')?><?php
     293                  ?><?=\__($strDesc, DOMAIN_PLUGIN)?><?php
    286294                ?></i><?php
    287295                if (\count($arrPosts) == 0) {
     
    295303                                                     : \sprintf(
    296304                                                        \__('[no name %d]',
    297                                                             'domain-plugin-LoginRequirePress'),
     305                                                            DOMAIN_PLUGIN),
    298306                                                        $objPost->ID)
    299307                               ?><?php
     
    325333                  'require user login, then submit the form by clicking \'%1$s\' at the top or ' .
    326334                  'bottom.',
    327                   'domain-plugin-LoginRequirePress'),
     335                  DOMAIN_PLUGIN),
    328336              \__('Update LR Settings',
    329                   'domain-plugin-LoginRequirePress'));
     337                  DOMAIN_PLUGIN));
    330338                   ?></p><?php
    331339            ?><p><?=\sprintf(
    332340              \__('After submitting the form, make sure that any post(s) you want ' .
    333341                  'login-protected are listed in the \'%1$s\' section below.',
    334                   'domain-plugin-LoginRequirePress'),
     342                  DOMAIN_PLUGIN),
    335343              \__('Non-private login-protected post(s)',
    336                   'domain-plugin-LoginRequirePress'))
     344                  DOMAIN_PLUGIN))
    337345                   ?></p><?php
    338346            ?><form method='post' action='admin-post.php'><?php
     
    346354                  $arrPasscodeProtected = [];
    347355              ?><input type='submit' value='<?=\__('Update LR Settings',
    348                                                    'domain-plugin-LoginRequirePress')
     356                                                   DOMAIN_PLUGIN)
    349357                                              ?>' class='button-primary'/><hr><?php
    350358              ?><table style='border-collapse:collapse'><?php
    351359                ?><tr><?php
    352360                  ?><th style='padding-right:15px;text-align:left'><?=
    353                     \__('LR', 'domain-plugin-LoginRequirePress')
    354                   ?></th><?php
    355                   ?><th style='padding-right:15px;text-align:left'><?=
    356                     \__('Current LR', 'domain-plugin-LoginRequirePress')
    357                   ?></th><?php
    358                   ?><th style='padding-right:15px;text-align:left'><?=
    359                     \__('ID', 'domain-plugin-LoginRequirePress')
    360                   ?></th><?php
    361                   ?><th style='padding-right:15px;text-align:left'><?=
    362                     \__('Post Name', 'domain-plugin-LoginRequirePress')
    363                   ?></th><?php
    364                   ?><th style='padding-right:15px;text-align:left'><?=
    365                     \__('Post Type', 'domain-plugin-LoginRequirePress')
    366                   ?></th><?php
    367                   ?><th style='padding-right:15px;text-align:left'><?=
    368                     \__('Page Template', 'domain-plugin-LoginRequirePress')
    369                   ?></th><?php
    370                   ?><th style='padding-right:15px;text-align:left'><?=
    371                     \__('Post Status', 'domain-plugin-LoginRequirePress')
    372                   ?></th><?php
    373                   ?><th style='padding-right:15px;text-align:left'><?=
    374                     \__('Default Visibility', 'domain-plugin-LoginRequirePress')
     361                    \__('LR', DOMAIN_PLUGIN)
     362                  ?></th><?php
     363                  ?><th style='padding-right:15px;text-align:left'><?=
     364                    \__('Current LR', DOMAIN_PLUGIN)
     365                  ?></th><?php
     366                  ?><th style='padding-right:15px;text-align:left'><?=
     367                    \__('ID', DOMAIN_PLUGIN)
     368                  ?></th><?php
     369                  ?><th style='padding-right:15px;text-align:left'><?=
     370                    \__('Post Name', DOMAIN_PLUGIN)
     371                  ?></th><?php
     372                  ?><th style='padding-right:15px;text-align:left'><?=
     373                    \__('Post Type', DOMAIN_PLUGIN)
     374                  ?></th><?php
     375                  ?><th style='padding-right:15px;text-align:left'><?=
     376                    \__('Page Template', DOMAIN_PLUGIN)
     377                  ?></th><?php
     378                  ?><th style='padding-right:15px;text-align:left'><?=
     379                    \__('Post Status', DOMAIN_PLUGIN)
     380                  ?></th><?php
     381                  ?><th style='padding-right:15px;text-align:left'><?=
     382                    \__('Default Visibility', DOMAIN_PLUGIN)
    375383                  ?></th><?php
    376384                ?></tr><?php
     
    387395                        $isPrivate = ($strPostStatus != 'publish');
    388396                        $strVisibility = $isPrivate ? \__('Private',
    389                                                           'domain-plugin-LoginRequirePress')
     397                                                          DOMAIN_PLUGIN)
    390398                                                    : \__('Public',
    391                                                           'domain-plugin-LoginRequirePress');
     399                                                          DOMAIN_PLUGIN);
    392400                        $isPasscodeProtected = ($post->post_password != null);
    393401                        if ($isPasscodeProtected) {
     
    417425                            if ($isLoginRequired) {
    418426                                ?><font color='red'><?php
    419                                   ?><?=\__(YES,'domain-plugin-LoginRequirePress')?><?php
     427                                  ?><?=\__(YES, DOMAIN_PLUGIN)?><?php
    420428                                ?></font><?php
    421429                            }
     
    438446              ?></table><?php
    439447              ?><hr><input type='submit' value='<?=\__('Update LR Settings',
    440                                                        'domain-plugin-LoginRequirePress')
     448                                                       DOMAIN_PLUGIN)
    441449                                                  ?>' class='button-primary'<?php
    442450                                                   ?> style='margin-bottom:3em'/><?php
     
    488496            $renderRefreshButton();
    489497        } else {
    490         ?><?=\__('No posts', 'domain-plugin-LoginRequirePress')?><?php
     498        ?><?=\__('No posts', DOMAIN_PLUGIN)?><?php
    491499        }
    492500    ?></div><?php
  • loginrequirepress/trunk/readme.txt

    r1478400 r1968416  
    33Tags: require login, password protect, security, limit access, control access, members, visitors, subscribers, require-login, password-protect, login-protect, limit-access
    44Requires at least: 3.8.1
    5 Tested up to: 4.6
    6 Stable tag: 1.2.0
     5Tested up to: 4.9.8
     6Stable tag: 1.3.0
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1414Overview:
    1515
    16   At the time of this writing, the latest version of WordPress, version 4.6,
     16  At the time of this writing, the latest version of WordPress, version 4.9.8,
    1717  has 3 post visibility options, which are 'public', 'password protected', and
    1818  'private'.
     
    2020  The 'password protected' option allows the site administrator to
    2121  individually lock certain posts, even from the logged in users, with an
    22   additional password.  However, there is currently no built-in way to just
    23   deny access only to the unauthenticated users.
     22  additional password / passcode.  However, there is currently no built-in way
     23  to just deny access only to the unauthenticated users.
    2424
    2525  Login Require Press is a WordPress plugin that allows site administrators to
     
    100100== Changelog ==
    101101
     102= 1.3.0 =
     103* Tested up to WordPress 4.9.8
     104* Added notice that changing settings in the meta box will not persist until the post is updated.
     105* Improved post filtering logic.
     106* Now also masking post excerpts of login-protected posts from search results.
     107
    102108= 1.2.0 =
    103109* Tested up to WordPress 4.6
Note: See TracChangeset for help on using the changeset viewer.