/** * The callback method for the campaigns shortcode. * * This receives the user-defined attributes and passes the logic off to the class. * * @param array $atts User-defined shortcode attributes. * @return string * @access public * @static * @since 1.4.0 */ public static function display($atts) { $defaults = array(); $args = shortcode_atts($defaults, $atts, 'charitable_my_donations'); ob_start(); /* If the user is logged out, redirect to login/registration page. */ if (!is_user_logged_in()) { echo Charitable_Login_Shortcode::display(array('redirect' => charitable_get_current_url())); return; } $user = charitable_get_user(get_current_user_id()); $view_args = array('donations' => new Charitable_Donations_Query(array('output' => 'posts', 'donor_id' => $user->get_donor_id(), 'orderby' => 'date', 'order' => 'DESC', 'number' => -1))); charitable_template('shortcodes/my-donations.php', $view_args); return apply_filters('charitable_my_donations_shortcode', ob_get_clean(), $args); }
if (!defined('ABSPATH')) { exit; } // Exit if accessed directly $content = $view_args['content']; if (is_user_logged_in()) { ?> <div class="charitable-notice"> <?php _e('You do not have access to this donation receipt.', 'charitable'); ?> </div> <?php } else { ?> <div class="charitable-notice"> <?php _e('You must be logged in to access your donation receipt.', 'charitable'); ?> </div> <?php charitable_template('shortcodes/login.php', array('redirect' => charitable_get_current_url())); ?> <?php }
/** * Checks whether the current requested page is in the user dashboard nav. * * @param Object $object Optional. If not set, will base it on the current queried object. * @return boolean * @access public * @since 1.0.0 */ public function in_nav() { global $wp; $found = false; $ret = wp_cache_get('charitable_in_user_dashboard', '', false, $found); if (false === $found) { $current_url = trailingslashit(charitable_get_current_url()); $ret = in_array(get_queried_object_id(), $this->nav_objects()) || in_array($current_url, $this->nav_objects()); $ret = apply_filters('charitable_is_in_user_dashboard', $ret, $this->nav_objects()); wp_cache_set('charitable_in_user_dashboard', $ret); } return $ret; }
/** * Checks whether the current request is for the campaign editing page. * * This is used when you call charitable_is_page( 'registration_page' ). * In general, you should use charitable_is_page() instead since it will * take into account any filtering by plugins/themes. * * @see charitable_is_page * @return boolean * @since 1.0.0 */ function charitable_is_registration_page($ret = false) { global $post; $page = charitable_get_option('registration_page', 'wp'); if ('wp' == $page) { $ret = wp_registration_url() == charitable_get_current_url(); } elseif (is_object($post)) { $ret = $page == $post->ID; } return $ret; }