Plugin Directory

Changeset 2088897

Timestamp:
05/16/2019 07:35:38 AM (5 years ago)
Author:
jamescollins
Message:

Log Out Shortcode v1.0.6

Location:
log-out-shortcode/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • log-out-shortcode/trunk/log-out-shortcode.php

    r1522833 r2088897  
    11<?php
    2 /*
     2/*
    33Plugin Name: Log Out Shortcode
    44Plugin URI: https://om4.com.au/plugins/log-out-shortcode/
    55Description: Easily add a log out link to a post or page using a simple <code>[logout]</code> shortcode.
    6 Version: 1.0.5
     6Version: 1.0.
    77Author: OM4
    88Author URI: https://om4.com.au/plugins/
    99Text Domain: log-out-shortcode
    1010License: GPLv2
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
    1129*/
    1230
    13 /*
    14 
    15    Copyright 2014-2016 OM4 (email: plugins@om4.com.au    web: https://om4.com.au/)
    16 
    17    This program is free software; you can redistribute it and/or modify
    18    it under the terms of the GNU General Public License as published by
    19    the Free Software Foundation; either version 2 of the License, or
    20    (at your option) any later version.
    21 
    22    This program is distributed in the hope that it will be useful,
    23    but WITHOUT ANY WARRANTY; without even the implied warranty of
    24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    25    GNU General Public License for more details.
    26 
    27    You should have received a copy of the GNU General Public License
    28    along with this program; if not, write to the Free Software
    29    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    30 */
    31 
    32 function logout_shortcode( $atts, $content = null, $shortcode_name = null ) {
     31/**
     32 * Create logout link
     33 *
     34 * @param array  $atts           The shortcode attributes.
     35 * @param string $content        The shortcode content (if any).
     36 * @param string $shortcode_name Name of the shortcode.
     37 * @return string
     38 */
     39function logout_shortcode( $atts, $content = '', $shortcode_name = '' ) {
    3340    $defaults = array(
    34             'text'     => __( 'Log out' ), // This is the default log out text from wp-includes/general-template.php
    35             'redirect' => '', // path/URL to redirect to after logging out
    36             'class'    => 'logout', // CSS Class(es) to use in link.
     41       
     42       
     43        'class'    => 'logout', // CSS Class(es) to use in link.
    3744    );
    3845
     
    4350    $atts = shortcode_atts( $defaults, $atts );
    4451
    45     if ( 'logout_to_home' == $shortcode_name ) {
     52    if ( 'logout_to_home' == $shortcode_name ) {
    4653        $atts['redirect'] = 'home';
    47     } else if ( 'logout_to_current' == $shortcode_name ) {
     54    } else== $shortcode_name ) {
    4855        $atts['redirect'] = 'current';
    4956    }
    5057
    51     if ( 'home' == $atts['redirect'] ) {
     58    if ( 'home' == $atts['redirect'] ) {
    5259            $atts['redirect'] = home_url();
    53     } else if ( 'current' == $atts['redirect'] ) {
     60    } else== $atts['redirect'] ) {
    5461        $atts['redirect'] = get_the_permalink();
    5562    }
    5663
    5764    $class_html = '';
    58     if ( '' != $atts['class'] ) {
    59         // Multiple classes are separated by a space
    60         $classes = explode( ' ', $atts['class'] );
    61         $classes = array_map( 'sanitize_html_class', $classes );
     65    if ( '' != $atts['class'] ) {
     66        // Multiple classes are separated by a space
     67        $classes = explode( ' ', $atts['class'] );
     68        $classes = array_map( 'sanitize_html_class', $classes );
    6269        $class_html = ' class="' . implode( $classes, ' ' ) . '"';
    6370    }
    6471
    65     return '<a href="' . esc_url( wp_logout_url( $atts['redirect'] ) ) . '"' . $class_html . '>'  . esc_html( $atts['text'] ) . '</a>';
     72    return '<a href="' . esc_url( wp_logout_url( $atts['redirect'] ) ) . '"' . $class_html . '>' . esc_html( $atts['text'] ) . '</a>';
    6673
    6774}
  • log-out-shortcode/trunk/readme.txt

    r1682376 r2088897  
    33Contributors: jamescollins
    44Requires at least: 3.9
    5 Tested up to: 4.8
    6 Stable tag: 1.0.5
     5Tested up to:
     6Stable tag: 1.0.
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363== Changelog ==
    6464
     65
     66
     67
    6568= 1.0.5 =
    6669* Fix a bug that meant it was not possible to use specify multiple classes in the class="" attribute. Thanks to @hughc for the bug report.
Note: See TracChangeset for help on using the changeset viewer.