| 1 |
<?php |
| 2 |
/** |
| 3 |
* Logout shortcode class. |
| 4 |
* |
| 5 |
* @package Charitable/Shortcodes/Logout |
| 6 |
* @author Eric Daams |
| 7 |
* @copyright Copyright (c) 2018, Studio 164a |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.5.0 |
| 10 |
* @version 1.5.7 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { exit; } |
| 15 |
|
| 16 |
if ( ! class_exists( 'Charitable_Logout_Shortcode' ) ) : |
| 17 |
|
| 18 |
/** |
| 19 |
* Charitable_Logout_Shortcode class. |
| 20 |
* |
| 21 |
* @since 1.5.0 |
| 22 |
*/ |
| 23 |
class Charitable_Logout_Shortcode { |
| 24 |
|
| 25 |
/** |
| 26 |
* The callback method for the logout shortcode. |
| 27 |
* |
| 28 |
* This receives the user-defined attributes and passes the logic off to the class. |
| 29 |
* |
| 30 |
* @since 1.5.0 |
| 31 |
* |
| 32 |
* @param array $atts User-defined shortcode attributes. |
| 33 |
* @return string |
| 34 |
*/ |
| 35 |
public static function display( $atts = array() ) { |
| 36 |
if ( ! is_user_logged_in() ) { |
| 37 |
return; |
| 38 |
} |
| 39 |
|
| 40 |
$defaults = array( |
| 41 |
'redirect' => charitable_get_current_url(), |
| 42 |
'text' => __( 'Logout', 'charitable' ), |
| 43 |
); |
| 44 |
|
| 45 |
$args = shortcode_atts( $defaults, $atts, 'charitable_logout' ); |
| 46 |
|
| 47 |
charitable_template( 'shortcodes/logout.php', $args ); |
| 48 |
|
| 49 |
/** |
| 50 |
* Filter the output of the login shortcode. |
| 51 |
* |
| 52 |
* @since 1.5.0 |
| 53 |
* |
| 54 |
* @param string $content Shortcode output. |
| 55 |
*/ |
| 56 |
return apply_filters( 'charitable_logout_shortcode', ob_get_clean() ); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
endif; |
| 61 |
|