| 1 |
<?php |
| 2 |
/** |
| 3 |
* Profile shortcode class. |
| 4 |
* |
| 5 |
* @package Charitable/Shortcodes/Profile |
| 6 |
* @author Eric Daams |
| 7 |
* @copyright Copyright (c) 2019, Studio 164a |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.0.0 |
| 10 |
* @version 1.5.7 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { exit; } |
| 15 |
|
| 16 |
if ( ! class_exists( 'Charitable_Profile_Shortcode' ) ) : |
| 17 |
|
| 18 |
/** |
| 19 |
* Charitable_Profile_Shortcode class. |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
*/ |
| 23 |
class Charitable_Profile_Shortcode { |
| 24 |
|
| 25 |
/** |
| 26 |
* The callback method for the campaigns shortcode. |
| 27 |
* |
| 28 |
* This receives the user-defined attributes and passes the logic off to the class. |
| 29 |
* |
| 30 |
* @since 1.0.0 |
| 31 |
* |
| 32 |
* @param array $atts User-defined shortcode attributes. |
| 33 |
* @return string |
| 34 |
*/ |
| 35 |
public static function display( $atts ) { |
| 36 |
$defaults = array( |
| 37 |
'hide_login' => false, |
| 38 |
); |
| 39 |
|
| 40 |
$args = shortcode_atts( $defaults, $atts, 'charitable_profile' ); |
| 41 |
|
| 42 |
ob_start(); |
| 43 |
|
| 44 |
/* If the user is logged out, show the login form. */ |
| 45 |
if ( ! is_user_logged_in() ) { |
| 46 |
|
| 47 |
if ( false == $args['hide_login'] ) { |
| 48 |
$args['redirect'] = charitable_get_current_url(); |
| 49 |
|
| 50 |
echo Charitable_Login_Shortcode::display( $args ); |
| 51 |
} |
| 52 |
|
| 53 |
return ob_get_clean(); |
| 54 |
} |
| 55 |
|
| 56 |
$args['form'] = new Charitable_Profile_Form( $args ); |
| 57 |
|
| 58 |
/* If the user is logged in, show the profile template. */ |
| 59 |
charitable_template( 'shortcodes/profile.php', $args ); |
| 60 |
|
| 61 |
return apply_filters( 'charitable_profile_shortcode', ob_get_clean() ); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
endif; |
| 66 |
|