/** * Display user name in profile.php template. * * @since 1.0.0 * @param object $user_data holds WP_User object * @access public * @return void */ function wpaam_profile_show_user_name($user_data) { $output = '<div class="wpaam-user-display-name">'; $output .= '<a href="' . wpaam_get_user_profile_url($user_data) . '">' . esc_attr($user_data->display_name) . '</a>'; // Show edit account only when viewing own profile if ($user_data->ID == get_current_user_id()) { $output .= '<small><a href="' . wpaam_get_core_page_url('account') . '" class="wpaam-profile-account-edit">' . __(' (Edit Account)', 'wpaam') . '</a></small>'; } $output .= '</div>'; echo $output; }
</a> </div> <div class="wpaam_three_fourth user-content last"> <a href="<?php echo esc_url($user_profile_user); ?> "><?php echo $current_user->display_name; ?> </a> <ul class="wpaam-overview-links"> <li><a href="<?php echo esc_url(wpaam_get_core_page_url('account')); ?> "><?php _e('Edit Account', 'wpaam'); ?> </a></li> <li>|</li> <li><a href="<?php echo esc_url(wpaam_logout_url(get_permalink())); ?> "><?php _e('Logout', 'wpaam'); ?> </a></li> </ul>
/** * Checks if profiles are available. * * @uses wpaam_is_single_profile * @uses wpaam_guests_can_view_profiles * @uses wpaam_members_can_view_profiles * @since 1.0.0 * @return bool */ function wpaam_can_access_profile() { $pass = true; // Check if not logged in and on profile page - no given user if (!is_user_logged_in() && !wpaam_is_single_profile()) { // Display error message $args = array('id' => 'wpaam-guests-disabled', 'type' => 'notice', 'text' => sprintf(__('This content is available to members only. Please <a href="%s">login</a> or <a href="%s">register</a> to view this area.', 'wpaam'), wpaam_get_core_page_url('login'), wpaam_get_core_page_url('register'))); wpaam_message($args); $pass = false; } // Block guests on single profile page if option disabled if (!is_user_logged_in() && wpaam_is_single_profile() && !wpaam_guests_can_view_profiles()) { // Display error message $args = array('id' => 'wpaam-guests-disabled', 'type' => 'notice', 'text' => sprintf(__('This content is available to members only. Please <a href="%s">login</a> or <a href="%s">register</a> to view this area.', 'wpaam'), wpaam_get_core_page_url('login'), wpaam_get_core_page_url('register'))); wpaam_message($args); $pass = false; } // Block members on single profile page if option disabled if (is_user_logged_in() && wpaam_is_single_profile() && !wpaam_members_can_view_profiles() && !wpaam_is_own_profile()) { // Display error message $args = array('id' => 'wpaam-no-access', 'type' => 'notice', 'text' => __('You are not authorized to access this area.', 'wpaam')); wpaam_message($args); $pass = false; } return apply_filters('wpaam_can_access_profile', $pass); }
/** * Displays the new settings section into the permalinks page. * * @access public * @since 1.0.0 * @return void */ public function display_settings() { $structures = wpaam_get_permalink_structures(); $saved_structure = get_option('wpaam_permalink', 'user_id'); ob_start(); ?> <?php if (get_option('permalink_structure') == '') { ?> <p><?php printf(__('You must <a href="%s">change your permalinks</a> to anything else other than "default" for profiles to work.', 'wpaam'), admin_url('options-permalink.php')); ?> </p> <?php } else { ?> <p><?php _e('These settings control the permalinks used for users profiles. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'wpaam'); ?> </p> <table class="form-table"> <tbody> <?php foreach ($structures as $key => $settings) { ?> <tr> <th> <label> <input name="user_permalink" type="radio" value="<?php echo $settings['name']; ?> " <?php checked($settings['name'], $saved_structure); ?> /> <?php echo $settings['label']; ?> </label> </th> <td> <code> <?php echo wpaam_get_core_page_url('profile'); echo $settings['sample']; ?> </code> </td> </tr> <?php } ?> <input type="hidden" name="wpaam-action" value="save_permalink_structure"/> </tbody> </table> <?php } ?> <?php echo ob_get_clean(); }
function wpaam_get_invoices_tab_url($tab) { if (get_option('permalink_structure') == '') { $tab_url = add_query_arg('invoice_tab', $tab, wpaam_get_core_page_url('invoices')); } else { $tab_url = wpaam_get_core_page_url('invoices') . $tab; } return esc_url($tab_url); }
/** * Login Form Shortcode **/ public function wpaam_login($atts, $content = null) { extract(shortcode_atts(array('redirect' => '', 'label' => esc_html__('Login', 'wpaam')), $atts)); $url = wpaam_get_core_page_url('login'); if (!empty($redirect)) { $url = add_query_arg(array('redirect_to' => urlencode($redirect)), $url); } $output = '<a href="' . esc_url($url) . '" class="wpaam-login-link">' . esc_html($label) . '</a>'; return $output; }
/** * Create a fake post object for the wp menu manager. * This function creates the list of Logged-Out only pages, * for the admin menu manager. * * @since 1.1.0 * @return array */ function wpaam_nav_menu_get_loggedout_pages() { $wpaam_menu_items = array(); $wpaam_menu_items[] = array('name' => __('Register', 'wpaam'), 'slug' => 'register', 'link' => wpaam_get_core_page_url('register')); $wpaam_menu_items[] = array('name' => __('Log in', 'wpaam'), 'slug' => 'login', 'link' => wpaam_get_core_page_url('login')); $wpaam_menu_items[] = array('name' => __('Password recovery', 'wpaam'), 'slug' => 'psw-recovery', 'link' => wpaam_get_core_page_url('password')); $wpaam_menu_items = apply_filters('wpaam_nav_menu_get_loggedout_pages', $wpaam_menu_items); // If there's nothing to show, we're done if (count($wpaam_menu_items) < 1) { return false; } $page_args = array(); foreach ($wpaam_menu_items as $wpaam_item) { $page_args[$wpaam_item['slug']] = (object) array('ID' => -1, 'post_title' => $wpaam_item['name'], 'post_author' => 0, 'post_date' => 0, 'post_excerpt' => $wpaam_item['slug'], 'post_type' => 'page', 'post_status' => 'publish', 'comment_status' => 'closed', 'guid' => $wpaam_item['link']); } return $page_args; }