Changeset 1397531
- Timestamp:
- 04/17/2016 03:09:39 AM (10 years ago)
- Location:
- loginrequirepress/trunk
- Files:
-
- 1 added
- 5 deleted
- 4 edited
-
INSTALL (deleted)
-
LICENSE (modified) (1 diff)
-
LoginRequirePress.php (modified) (13 diffs)
-
README (deleted)
-
RELEASE_NOTES (deleted)
-
REQUIREMENTS (deleted)
-
VERSION (deleted)
-
readme.txt (modified) (6 diffs)
-
screenshot-1.gif (modified) (previous)
-
screenshot-2.gif (added)
Legend:
- Unmodified
- Added
- Removed
-
loginrequirepress/trunk/LICENSE
r1193830 r1397531 28 28 http://www.maratbn.com/projects/login-require-press 29 29 30 Copyright (C) 2015 Marat Nepomnyashy http://maratbn.com maratbn@gmail30 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 31 31 32 Version: 0.1.3-development_unreleased32 Version: 1.1.0-development_unreleased 33 33 34 Module: LICENSE34 Module: loginrequirepress/LICENSE 35 35 36 36 Description: License for LoginRequirePress. -
loginrequirepress/trunk/LoginRequirePress.php
r1193830 r1397531 9 9 Author URI: http://www.maratbn.com 10 10 License: GPL3 11 Version: 0.1.3-development_unreleased11 Version: 1.1.0-development_unreleased 12 12 Text Domain: domain-plugin-LoginRequirePress 13 13 */ … … 43 43 http://www.maratbn.com/projects/login-require-press 44 44 45 Copyright (C) 2015 Marat Nepomnyashy http://maratbn.com maratbn@gmail46 47 Version: 0.1.3-development_unreleased45 Copyright (C) 2015-2016 Marat Nepomnyashy http://maratbn.com maratbn@gmail 46 47 Version: 1.1.0-development_unreleased 48 48 49 49 Module: LoginRequirePress.php … … 72 72 73 73 74 const PHP_VERSION_MIN_SUPPORTED = '5.4'; 75 74 76 const LOGIN_REQUIRE_PRESS = 'login_require_press'; 75 77 const YES = 'yes'; 76 78 77 add_action('admin_menu', '\\plugin_LoginRequirePress\\action_admin_menu');78 add_action('admin_post_plugin_LoginRequirePress_settings',79 '\\plugin_LoginRequirePress\\action_admin_post_plugin_LoginRequirePress_settings');80 add_action('send_headers', '\\plugin_LoginRequirePress\\action_send_headers');81 82 add_filter('plugin_action_links_' .plugin_basename(__FILE__),79 \add_action('admin_menu', '\\plugin_LoginRequirePress\\action_admin_menu'); 80 \add_action('admin_post_plugin_LoginRequirePress_settings', 81 '\\plugin_LoginRequirePress\\action_admin_post_plugin_LoginRequirePress_settings'); 82 \add_action('send_headers', '\\plugin_LoginRequirePress\\action_send_headers'); 83 84 \add_filter('plugin_action_links_' . \plugin_basename(__FILE__), 83 85 '\\plugin_LoginRequirePress\\filter_plugin_action_links'); 84 add_filter('posts_results', '\\plugin_LoginRequirePress\\filter_posts_results'); 86 \add_filter('posts_results', '\\plugin_LoginRequirePress\\filter_posts_results'); 87 88 \register_activation_hook(__FILE__, '\\plugin_LoginRequirePress\\plugin_activation_hook'); 85 89 86 90 87 91 function action_admin_menu() { 88 add_options_page(__('LoginRequirePress Settings', 'domain-plugin-LoginRequirePress'),89 __('LoginRequirePress', 'domain-plugin-LoginRequirePress'),92 \add_options_page(\__('LoginRequirePress Settings', 'domain-plugin-LoginRequirePress'), 93 \__('LoginRequirePress', 'domain-plugin-LoginRequirePress'), 90 94 'manage_options', 91 95 'plugin_LoginRequirePress_settings', … … 95 99 function action_admin_post_plugin_LoginRequirePress_settings() { 96 100 // Based on: http://jaskokoyn.com/2013/03/26/wordpress-admin-forms/ 97 if (! current_user_can('manage_options')) {98 wp_die(__('Insufficient user permissions to modify options.',99 'domain-plugin-LoginRequirePress'));101 if (!\current_user_can('manage_options')) { 102 \wp_die(\__('Insufficient user permissions to modify options.', 103 'domain-plugin-LoginRequirePress')); 100 104 } 101 105 102 106 // Check that nonce field 103 check_admin_referer('plugin_LoginRequirePress_settings_nonce');107 \check_admin_referer('plugin_LoginRequirePress_settings_nonce'); 104 108 105 109 foreach ($_POST as $strFieldName => $strFieldValue) { 106 preg_match('/^post_(\d+)$/', $strFieldName, $arrMatch);107 if ($arrMatch && count($arrMatch) == 2) {110 \preg_match('/^post_(\d+)$/', $strFieldName, $arrMatch); 111 if ($arrMatch && \count($arrMatch) == 2) { 108 112 $idPost = $arrMatch[1]; 109 113 $flagIsLocked = isset($_POST['lock_' . $idPost]); … … 116 120 } 117 121 118 wp_redirect(getUrlSettings());122 \wp_redirect(getUrlSettings()); 119 123 exit(); 120 124 } … … 123 127 124 128 // No need to redirect to the login page if the user is already logged in. 125 if ( is_user_logged_in()) return;129 if (\is_user_logged_in()) return; 126 130 127 131 global $wp; … … 144 148 $w_p_query->the_post(); 145 149 if (isLoginRequiredForPost($post)) { 146 \header('Location: ' . wp_login_url(home_url($_SERVER['REQUEST_URI'])));150 \header('Location: ' . \wp_login_url(\home_url($_SERVER['REQUEST_URI']))); 147 151 exit(0); 148 152 } 149 153 } 150 wp_reset_postdata();154 \wp_reset_postdata(); 151 155 } 152 156 } 153 157 154 158 function filter_plugin_action_links($arrLinks) { 155 array_push($arrLinks,156 '<a href=\'' . getUrlSettings() . '\'>'157 .__('Settings', 'domain-plugin-LoginRequirePress') . '</a>');159 \array_push($arrLinks, 160 '<a href=\'' . getUrlSettings() . '\'>' 161 . \__('Settings', 'domain-plugin-LoginRequirePress') . '</a>'); 158 162 return $arrLinks; 159 163 } … … 174 178 if (isLoginRequiredForPost($post)) { 175 179 if ($flagIsSearchNotLoggedIn) { 176 $post->post_content = __('[Post content protected by LoginRequirePress. Login to see the content.]',177 'domain-plugin-LoginRequirePress');178 $post->post_title = __('[Post title protected by LoginRequirePress. Login to see the title.]',179 'domain-plugin-LoginRequirePress');180 $post->post_content = \__('[Post content protected by LoginRequirePress. Login to see the content.]', 181 'domain-plugin-LoginRequirePress'); 182 $post->post_title = \__('[Post title protected by LoginRequirePress. Login to see the title.]', 183 'domain-plugin-LoginRequirePress'); 180 184 } else { 181 185 continue; … … 183 187 } 184 188 185 array_push($arrPostsFiltered, $post);189 \array_push($arrPostsFiltered, $post); 186 190 } 187 191 … … 190 194 191 195 function getUrlSettings() { 192 return admin_url('options-general.php?page=plugin_LoginRequirePress_settings');196 return \admin_url('options-general.php?page=plugin_LoginRequirePress_settings'); 193 197 } 194 198 195 199 function isLoginRequiredForPost(&$post) { 196 return (strcasecmp(YES, \get_post_meta($post->ID, 197 LOGIN_REQUIRE_PRESS, 198 true)) == 0); 200 return (\strcasecmp(YES, \get_post_meta($post->ID, 201 LOGIN_REQUIRE_PRESS, 202 true)) == 0); 203 } 204 205 function plugin_activation_hook() { 206 if (\version_compare(\strtolower(PHP_VERSION), PHP_VERSION_MIN_SUPPORTED, '<')) { 207 \wp_die( 208 \sprintf(\__('LoginRequirePress plugin cannot be activated because the currently active PHP version on this server is < %s and not supported. PHP version >= %s is required.', 209 'domain-plugin-LoginRequirePress'), 210 PHP_VERSION_MIN_SUPPORTED)); 211 } 199 212 } 200 213 201 214 function render_settings() { 202 215 // Based on http://codex.wordpress.org/Administration_Menus 203 if (! current_user_can('manage_options' )) {204 wp_die(__('You do not have sufficient permissions to access this page.',205 'domain-plugin-LoginRequirePress'));216 if (!\current_user_can('manage_options' )) { 217 \wp_die(\__('You do not have sufficient permissions to access this page.', 218 'domain-plugin-LoginRequirePress')); 206 219 } 207 220 ?><div class="wrap"><?php 208 ?><p><?= sprintf(209 __('Check the checkbox(es) corresponding to the post(s) for which you want to require ' .210 'user login, then submit the form by clicking \'%1$s\' at the top or bottom.',211 'domain-plugin-LoginRequirePress'),212 __('Update LR Settings',213 'domain-plugin-LoginRequirePress'));221 ?><p><?=\sprintf( 222 \__('Check the checkbox(es) corresponding to the post(s) for which you want to require ' . 223 'user login, then submit the form by clicking \'%1$s\' at the top or bottom.', 224 'domain-plugin-LoginRequirePress'), 225 \__('Update LR Settings', 226 'domain-plugin-LoginRequirePress')); 214 227 ?></p><?php 215 228 ?><form method='post' action='admin-post.php'><?php 216 229 ?><input type='hidden' name='action' value='plugin_LoginRequirePress_settings' /><?php 217 wp_nonce_field('plugin_LoginRequirePress_settings_nonce');230 \wp_nonce_field('plugin_LoginRequirePress_settings_nonce'); 218 231 219 232 $w_p_query = new \WP_Query(['order' => 'ASC', … … 225 238 global $post; 226 239 if ($w_p_query->have_posts()) { 227 ?><input type='submit' value='<?=__('Update LR Settings', 228 'domain-plugin-LoginRequirePress') 240 $arrNonPrivateLoginProtected = []; 241 $arrPrivate = []; 242 $arrPasscodeProtected = []; 243 ?><input type='submit' value='<?=\__('Update LR Settings', 244 'domain-plugin-LoginRequirePress') 229 245 ?>' class='button-primary'/><hr><?php 230 246 ?><table style='border-collapse:collapse'><?php 231 247 ?><tr><?php 232 248 ?><th style='padding-right:15px;text-align:left'><?= 233 __('LR', 'domain-plugin-LoginRequirePress') 234 ?></th><?php 235 ?><th style='padding-right:15px;text-align:left'><?= 236 __('Current LR', 'domain-plugin-LoginRequirePress') 237 ?></th><?php 238 ?><th style='padding-right:15px;text-align:left'><?= 239 __('ID', 'domain-plugin-LoginRequirePress') 240 ?></th><?php 241 ?><th style='padding-right:15px;text-align:left'><?= 242 __('Post Name', 'domain-plugin-LoginRequirePress') 243 ?></th><?php 244 ?><th style='padding-right:15px;text-align:left'><?= 245 __('Post Type', 'domain-plugin-LoginRequirePress') 246 ?></th><?php 247 ?><th style='padding-right:15px;text-align:left'><?= 248 __('Page Template', 'domain-plugin-LoginRequirePress') 249 ?></th><?php 250 ?><th style='padding-right:15px;text-align:left'><?= 251 __('Post Status', 'domain-plugin-LoginRequirePress') 249 \__('LR', 'domain-plugin-LoginRequirePress') 250 ?></th><?php 251 ?><th style='padding-right:15px;text-align:left'><?= 252 \__('Current LR', 'domain-plugin-LoginRequirePress') 253 ?></th><?php 254 ?><th style='padding-right:15px;text-align:left'><?= 255 \__('ID', 'domain-plugin-LoginRequirePress') 256 ?></th><?php 257 ?><th style='padding-right:15px;text-align:left'><?= 258 \__('Post Name', 'domain-plugin-LoginRequirePress') 259 ?></th><?php 260 ?><th style='padding-right:15px;text-align:left'><?= 261 \__('Post Type', 'domain-plugin-LoginRequirePress') 262 ?></th><?php 263 ?><th style='padding-right:15px;text-align:left'><?= 264 \__('Page Template', 'domain-plugin-LoginRequirePress') 265 ?></th><?php 266 ?><th style='padding-right:15px;text-align:left'><?= 267 \__('Post Status', 'domain-plugin-LoginRequirePress') 268 ?></th><?php 269 ?><th style='padding-right:15px;text-align:left'><?= 270 \__('Default Visibility', 'domain-plugin-LoginRequirePress') 252 271 ?></th><?php 253 272 ?></tr><?php … … 258 277 $isLoginRequired = isLoginRequiredForPost($post); 259 278 $strPostName = $post->post_name; 279 $urlPostEdit = \get_edit_post_link($idPost); 280 $strPostStatus = \get_post_status($idPost); 281 $isPrivate = ($strPostStatus == 'private'); 282 $strVisibility = $isPrivate ? \__('Private', 'domain-plugin-LoginRequirePress') 283 : \__('Public', 'domain-plugin-LoginRequirePress'); 284 $isPasscodeProtected = ($post->post_password != null); 285 if ($isPasscodeProtected) { 286 $strVisibility = \__('Password protected'); 287 } 288 289 if ($isPrivate) { 290 \array_push($arrPrivate, $post); 291 } else if ($isLoginRequired) { 292 \array_push($arrNonPrivateLoginProtected, $post); 293 } 294 if ($isPasscodeProtected) { 295 \array_push($arrPasscodeProtected, $post); 296 } 260 297 ?><input type='hidden' name='post_<?=$idPost?>'><?php 261 298 ?><tr <?=$indexRow % 2 == 0 … … 268 305 <?php 269 306 if ($isLoginRequired) { 270 echo YES; 307 ?><font color='red'><?php 308 ?><?=\__(YES,'domain-plugin-LoginRequirePress')?><?php 309 ?></font><?php 271 310 } 272 311 ?> 273 312 </td> 274 <td><a href='<?= get_edit_post_link($idPost)?>'><?=$idPost?></a></td>275 <td><a href='<?= get_edit_post_link($idPost)?>'><?=$strPostName?></a></td>313 <td><a href='<?=$urlPostEdit?>'><?=$idPost?></a></td> 314 <td><a href='<?=$urlPostEdit?>'><?=$strPostName?></a></td> 276 315 <td><?=$post->post_type?></td> 277 <td><?=get_page_template_slug($idPost)?></td> 278 <td><?=get_post_status($idPost)?></td> 316 <td><?=\get_page_template_slug($idPost)?></td> 317 <td style='<?=$isPrivate ? 'color:red' : "" ?>'> 318 <?=$strPostStatus?> 319 </td> 320 <td style='<?=$isPrivate || $isPasscodeProtected ? 'color:red' : "" ?>'> 321 <?=$strVisibility?> 322 </td> 279 323 </tr><?php 280 324 $indexRow++; 281 325 } 282 wp_reset_postdata();326 \wp_reset_postdata(); 283 327 ?></table><?php 284 ?><hr><input type='submit' value='<?=__('Update LR Settings', 285 'domain-plugin-LoginRequirePress') 286 ?>' class='button-primary'/><?php 328 ?><hr><input type='submit' value='<?=\__('Update LR Settings', 329 'domain-plugin-LoginRequirePress') 330 ?>' class='button-primary'<?php 331 ?> style='margin-bottom:3em'/><?php 332 333 if (\count($arrPrivate) > 0) { 334 ?><hr><?php 335 ?><h3><?php 336 ?><?=\__('Private post(s):', 337 'domain-plugin-LoginRequirePress')?><?php 338 ?></h3><?php 339 ?><i><?php 340 ?><?=\__('These posts are invisible to the public, as well as to the logged-in Subscribers, Contributors, and other Authors. Post visibility can be edited on each post\'s edit page.', 341 'domain-plugin-LoginRequirePress')?><?php 342 ?></i><?php 343 ?><ul><?php 344 foreach ($arrPrivate as $postPrivate) { 345 ?><li><?php 346 ?><a href='<?=\get_edit_post_link($postPrivate->ID)?>'><?php 347 ?><?=$postPrivate->post_name?><?php 348 ?></a><?php 349 ?></li><?php 350 } 351 ?></ul><?php 352 } 353 354 if (\count($arrNonPrivateLoginProtected) > 0) { 355 ?><hr><?php 356 ?><h3><?php 357 ?><?=\__('Non-private login-protected post(s):', 358 'domain-plugin-LoginRequirePress')?><?php 359 ?></h3><?php 360 ?><i><?php 361 ?><?=\__('These posts will require user login to see, but all logged-in users will be able to see them, hence they\'re not "private". The login protection can be modified in the table above.', 362 'domain-plugin-LoginRequirePress')?><?php 363 ?></i><?php 364 ?><ul><?php 365 foreach ($arrNonPrivateLoginProtected as $postLoginProtected) { 366 ?><li><?php 367 ?><a href='<?=\get_edit_post_link($postLoginProtected->ID)?>'><?php 368 ?><?=$postLoginProtected->post_name?><?php 369 ?></a><?php 370 ?></li><?php 371 } 372 ?></ul><?php 373 } 374 375 if (\count($arrPasscodeProtected) > 0) { 376 ?><hr><?php 377 ?><h3><?php 378 ?><?=\__('Passcode-protected post(s):', 379 'domain-plugin-LoginRequirePress')?><?php 380 ?></h3><?php 381 ?><i><?php 382 ?><?=\__('Also known as the WordPress "Password Protected" posts, but different from login-protected. The content of any of these posts will be invisible to the public, as well as to any logged-in users, until they enter a special post-only passcode / password, previously chosen in the Post Visibility section of each of these posts\' edit pages. Any post that is both login protected and "Password Protected" will require user login, and then the entry of the additional post-only passcode to see its content.', 383 'domain-plugin-LoginRequirePress')?><?php 384 ?></i><?php 385 ?><ul><?php 386 foreach ($arrPasscodeProtected as $postPasscodeProtected) { 387 ?><li><?php 388 ?><a href='<?=\get_edit_post_link($postPasscodeProtected->ID)?>'><?php 389 ?><?=$postPasscodeProtected->post_name?><?php 390 ?></a><?php 391 ?></li><?php 392 } 393 ?></ul><?php 394 } 287 395 } else { 288 ?><?= __('No posts', 'domain-plugin-LoginRequirePress')?><?php396 ?><?=\__('No posts', 'domain-plugin-LoginRequirePress')?><?php 289 397 } 290 398 ?></form></div><?php -
loginrequirepress/trunk/readme.txt
r1202010 r1397531 3 3 Tags: require login, password protect, security, limit access, control access, members, visitors, subscribers 4 4 Requires at least: 3.8.1 5 Tested up to: 4. 2.26 Stable tag: 0.1.25 Tested up to: 4.5 6 Stable tag: 1.0.0 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 14 14 Overview: 15 15 16 At the time of this writing, the latest version of WordPress, version 4. 2.2,16 At the time of this writing, the latest version of WordPress, version 4.5, 17 17 has 3 post visibility options, which are 'public', 'password protected', and 18 18 'private'. … … 53 53 page listings. 54 54 55 Login-requiring posts are marked with a custom field 'login_require_press' set to 'yes'. 56 55 57 Official project URLs: 56 58 … … 66 68 == Frequently Asked Questions == 67 69 70 = What do I do if I get this error "Plugin could not be activated because it triggered a fatal error." when trying to activate? = 71 72 Upgrade to PHP >= 5.4 See 73 https://wordpress.org/support/topic/crashes-on-activate 74 75 Make sure to check your PHP version with 76 https://wordpress.org/plugins/display-php-version/ 77 68 78 = Where can I ask a question about LoginRequirePress? = 69 79 … … 74 84 Post issues / bugs / feature requests at: https://github.com/maratbn/LoginRequirePress/issues 75 85 86 = Plugin is missing feature X that I really want, what do I do? = 87 88 Post a bug / feature request, or implement the feature at your leisure, and submit a pull request. 89 76 90 == Screenshots == 77 91 78 1. LoginRequirePress configuration screen. 92 1. LoginRequirePress configuration screen with the table used to specify which posts are to be 93 login-protected. 94 95 2. LoginRequirePress configuration screen with the lists of private, non-private login-protected, 96 and passcode-protected posts. 79 97 80 98 == Changelog == 81 99 82 = 0.1.0 = 83 * Initial release. 84 85 = 0.1.1 = 86 * Various documentation improvement. 100 = 1.0.0 = 101 * Version incremented to 1.0.0 to signify public release. 102 * Tested up to WordPress 4.5 103 * Login Required status indicators now in red. 104 * Added new 'Default Visibility' column, that indicates posts' present visibility according to the 105 default WordPress logic without this plugin. 106 * Explicitly listing-out the Private, Login-Protected, and Passcode/Password-Protected posts. 107 * Added plugin activation check for PHP version >= 5.4 108 * Revised screenshot 1 to display the latest UI, and added screenshot 2. 87 109 88 110 = 0.1.2 = … … 91 113 * Fixed issue https://github.com/maratbn/LoginRequirePress/issues/3: Protecting the titles and 92 114 contents of login-requiring posts in search result page listings when the user is not logged in. 115 116 = 0.1.1 = 117 * Various documentation improvement. 118 119 = 0.1.0 = 120 * Initial release.
Note: See TracChangeset
for help on using the changeset viewer.