WordPress.org

Plugin Directory

Changeset 620680


Ignore:
Timestamp:
11/03/12 13:09:19 (18 months ago)
Author:
johnbillion
Message:
  • Better compatibility with the post password system WordPress 3.4.
  • Only show the log out link on posts which are password protected.
Location:
logout-password-protected-posts/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • logout-password-protected-posts/trunk/logout.php

    r199068 r620680  
    44Description:  Provides a template tag for a link for visitors to log out of password protected posts. Add <code>do_action('posts_logout_link')</code> to your theme where you want the link to appear. 
    55Plugin URI:   http://lud.icro.us/wordpress-plugin-logout-password-protected-posts/ 
    6 Version:      0.1 
     6Version:      0.2 
    77Author:       John Blackbourn 
    88Author URI:   http://johnblackbourn.com/ 
    9 License:      GNU General Public License 
     9License:      GPL v2 or later 
    1010 
    11     This program is free software; you can redistribute it and/or modify 
    12     it under the terms of the GNU General Public License as published by 
    13     the Free Software Foundation; either version 2 of the License, or 
    14     (at your option) any later version. 
     11Copyright © 2012 John Blackbourn 
    1512 
    16     This program is distributed in the hope that it will be useful, 
    17     but WITHOUT ANY WARRANTY; without even the implied warranty of 
    18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    19     GNU General Public License for more details. 
     13This program is free software; you can redistribute it and/or modify 
     14it under the terms of the GNU General Public License as published by 
     15the Free Software Foundation; either version 2 of the License, or 
     16(at your option) any later version. 
     17 
     18This program is distributed in the hope that it will be useful, 
     19but WITHOUT ANY WARRANTY; without even the implied warranty of 
     20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     21GNU General Public License for more details. 
    2022 
    2123*/ 
     
    3133 
    3234function posts_logout_url() { 
    33     return wp_nonce_url( add_query_arg( array( 'action' => 'posts_logout' ), get_bloginfo('home') . '/' ), 'posts_logout' ); 
     35    return wp_nonce_url( add_query_arg( array( 'action' => 'posts_logout' ), site_url( 'wp-login.php', 'login' ) ), 'posts_logout' ); 
    3436} 
    3537 
    3638function posts_logout_link( $text = '', $class = '' ) { 
     39 
     40    global $post; 
     41 
     42    if ( empty( $post ) or !$post->post_password ) 
     43        return; 
    3744    if ( !isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ) 
    3845        return; 
     46    if ( empty( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ) 
     47        return; 
     48 
    3949    if ( !$text ) 
    4050        $text = 'Log out of password protected posts'; 
    4151    if ( $class ) 
    4252        $class = ' class="' . $class . '"'; 
     53 
    4354    echo '<a href="' . posts_logout_url() . '"' . $class . '>' . $text . '</a>'; 
     55 
    4456} 
    4557 
  • logout-password-protected-posts/trunk/readme.txt

    r424490 r620680  
    22Contributors: johnbillion 
    33Tags: password, logout 
    4 Requires at least: 2.7 
    5 Tested up to: 3.2 
     4Requires at least: 3.4 
     5Tested up to: 3.5 
    66Stable tag: trunk 
    77 
    8 Provides a template tag for a link for visitors to log out of password protected posts. Add <code>do_action('posts_logout_link')</code> to your theme where you want the link to appear. 
     8Provides a template tag for a link for visitors to log out of password protected posts. 
    99 
    1010== Description == 
    1111 
    12 There is no built-in way for your visitors to "log out" of password protected posts once they've entered the password. Even logged in users cannot log out of password protected posts by logging out of their account. This plugin solves that problem by providing a link for your visitors which will log them out of password protected posts when clicked. 
     12There is no built-in way for your visitors to "log out" of password protected posts once they've entered the password. Even logged in users cannot log out of password protected posts by logging out of their account. This plugin solves that problem by providing a link for your visitors to log out of password protected posts. 
     13 
     14After installing the plugin, add <code><?php do_action('posts_logout_link'); ?></code> somewhere in your theme to display a link for logging out of password protected posts. 
    1315 
    1416== Installation == 
    1517 
    16 1. Unzip the ZIP file and drop the folder straight into your wp-content/plugins directory. 
    17 2. Activate the plugin through the 'Plugins' menu in WordPress. 
    18 3. Add <code><?php do_action('posts_logout_link'); ?></code> somewhere in your theme. 
     18You can install this plugin directly from your WordPress dashboard: 
     19 
     20 1. Go to the *Plugins* menu and click *Add New*. 
     21 2. Search for *Logout Password Protected Posts*. 
     22 3. Click *Install Now* next to the Logout Password Protected Posts plugin. 
     23 4. Activate the plugin. 
     24 5. Add <code><?php do_action('posts_logout_link'); ?></code> somewhere in your theme. 
    1925 
    2026Those people who are logged in to password protected posts will now see a link to log out. 
    2127 
     28For manual installation, see the guide to [Manually Installing Plugins](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation). 
     29 
    2230== Frequently Asked Questions == 
    2331 
    24 = I've added the template tag to my theme but can't see the link. What's up? = 
     32= I can't see a link to log out. What's up? = 
     33 
     34Have you added the template tag somewhere in your theme? You need to add <code><?php do_action('posts_logout_link'); ?></code> somewhere in your theme for the link to show up. 
     35 
     36= I've added the template tag to my theme but I can't see the log out link. What's up? = 
    2537 
    2638Ensure that you have entered a password for a password protected post. The link will not show up if you're not logged into a password protected post. 
     
    3244For those who want even more control, you can also add a third paramter which will be used as the class name on the link element. 
    3345 
     46== Upgrade Notice == 
     47 
     48= 0.2 = 
     49* Better compatibility with WordPress 3.4. Only show the log out link on posts which are password protected. 
     50 
    3451== Changelog == 
     52== Changelog == 
     53 
     54= 0.2 = 
     55* Better compatibility with the post password system WordPress 3.4. 
     56* Only show the log out link on posts which are password protected. 
    3557 
    3658= 0.1 = 
Note: See TracChangeset for help on using the changeset viewer.