/** * Overwrites the `do_trail_items()` method and creates custom trail items. * * @since 1.0.0 * @access public * @return void */ public function do_trail_items() { /* Add the network and site home links. */ $this->do_network_home_link(); $this->do_site_home_link(); $this->mb_do_board_home_link(); /* Single forum, topic, or reply. */ if (mb_is_single_forum() || mb_is_single_topic() || mb_is_single_reply()) { $this->do_singular_items(); } elseif (mb_is_forum_archive() || mb_is_topic_archive() || mb_is_reply_archive()) { $this->do_post_type_archive_items(); } elseif (mb_is_role_archive()) { $this->mb_do_user_archive_link(); if (is_paged()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_role_archive_url(), mb_get_role_archive_title()); } elseif ($this->args['show_title']) { $this->items[] = mb_get_role_archive_title(); } } elseif (mb_is_single_role()) { $this->mb_do_user_archive_link(); $this->mb_do_role_archive_link(); if (is_paged()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_role_url(), mb_get_single_role_title()); } elseif ($this->args['show_title']) { $this->items[] = mb_get_single_role_title(); } } elseif (mb_is_user_archive()) { if (is_paged()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_archive_url(), mb_get_user_archive_title()); } elseif ($this->args['show_title']) { $this->items[] = mb_get_user_archive_title(); } } elseif (mb_is_single_user()) { $this->mb_do_user_archive_link(); /* If single user subpage. */ if (mb_is_user_page()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_url(), get_the_author_meta('display_name', mb_get_user_id())); if (is_paged()) { if (mb_is_user_forums()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_forums_url(), mb_get_user_forums_title()); } elseif (mb_is_user_topics()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_topics_url(), mb_get_user_topics_title()); } elseif (mb_is_user_replies()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_replies_url(), mb_get_user_replies_title()); } elseif (mb_is_user_bookmarks()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_bookmarks_url(), mb_get_user_bookmarks_title()); } elseif (mb_is_user_forum_subscriptions()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_forum_subscriptions_url(), mb_get_user_forum_subscriptions_title()); } elseif (mb_is_user_topic_subscriptions()) { $this->items[] = sprintf('<a href="%s">%s</a>', mb_get_user_topic_subscriptions_url(), mb_get_user_topic_subscriptions_title()); } } elseif ($this->args['show_title']) { $this->items[] = mb_get_user_page_title(); } /* If viewing the single user page but not a subpage. */ } elseif ($this->args['show_title']) { $this->items[] = mb_get_single_user_title(); } /* Login page. */ } elseif (mb_is_forum_login()) { $this->items[] = mb_get_login_page_title(); } /* Add paged items. */ $this->do_paged_items(); /* Return the board breadcrumb trail items. */ $this->items = apply_filters('mb_get_breadcrumb_trail_items', $this->items, $this->args); }
/** * Returns a single user forum subscriptions URL. * * @since 1.0.0 * @access public * @param int $user_id * @global object $wp_rewrite * @return string */ function mb_get_user_forum_subscriptions_url($user_id = 0) { global $wp_rewrite; $user_id = mb_get_user_id($user_id); $url = mb_get_user_url($user_id); if ($wp_rewrite->using_permalinks()) { $url = user_trailingslashit(trailingslashit($url) . 'forum-subscriptions'); } else { $url = add_query_arg(array('mb_user_page' => 'forum-subscriptions'), $url); } return apply_filters('mb_user_forum_subscriptions_url', $url, $user_id); }
function mb_get_post_author_profile_url($post_id = 0) { $post_id = mb_get_post_id($post_id); $author_id = mb_get_post_author_id($post_id); $profile_url = mb_get_user_url($author_id); return apply_filters('mb_get_post_author_profile_url', $profile_url, $author_id, $post_id); }
function mb_handler_edit_user() { /* Verify the nonce. */ if (!mb_check_post_nonce('mb_edit_user_nonce', 'mb_edit_user_action')) { return; } /* Get the user ID. */ $user_id = mb_get_user_id($_POST['mb_user_id']); /* Make sure the current user can edit the user. */ if (!current_user_can('edit_user', $user_id)) { mb_bring_the_doom('no-permission'); } /* Get the user object. */ $user = new WP_User($user_id); $first_name = !empty($_POST['mb_first_name']) ? esc_html(strip_tags($_POST['mb_first_name'])) : ''; $last_name = !empty($_POST['mb_last_name']) ? esc_html(strip_tags($_POST['mb_last_name'])) : ''; $nickname = !empty($_POST['mb_nickname']) ? esc_html(strip_tags($_POST['mb_nickname'])) : $user->user_login; $url = !empty($_POST['mb_url']) ? esc_url_raw($_POST['mb_url']) : ''; $email = isset($_POST['mb_email']) ? sanitize_email($_POST['mb_email']) : ''; if (empty($email) || !is_email($email) || email_exists($email)) { $email = $user->user_email; } $args = array('ID' => $user->ID, 'first_name' => $first_name, 'last_name' => $last_name, 'nickname' => $nickname, 'user_email' => $email, 'user_url' => $url); if (!empty($_POST['pass1']) && !empty($_POST['pass2']) && $_POST['pass1'] === $_POST['pass2']) { $args['user_pass'] = $_POST['pass1']; } $updated = wp_update_user($args); if ($updated && !is_wp_error($updated)) { // @todo User contact methods... /* Currently-saved meta. */ $desc_meta = get_user_meta($user_id, 'description', true); /* Posted meta. */ $description = !empty($_POST['mb_description']) ? mb_filter_post_kses($_POST['mb_description']) : ''; if ($desc_meta !== $description) { update_user_meta($user_id, 'description', $description); } /* Redirect to user profile. */ wp_safe_redirect(mb_get_user_url($user_id)); } }
/** * Returns the reply author URL. * * @since 1.0.0 * @access public * @param int $reply_id * @return string */ function mb_get_reply_author_url($reply_id = 0) { $reply_id = mb_get_reply_id($reply_id); $author_id = mb_get_reply_author_id($reply_id); $author_url = $author_id ? mb_get_user_url($author_id) : ''; return apply_filters('mb_get_reply_author_url', $author_url, $reply_id); }
/** * Returns the forum author URL. * * @since 1.0.0 * @access public * @param int $forum_id * @return string */ function mb_get_forum_author_url($forum_id = 0) { $forum_id = mb_get_forum_id($forum_id); $author_id = mb_get_forum_author_id($forum_id); $author_url = $author_id ? mb_get_user_url($author_id) : ''; return apply_filters('mb_get_forum_author_url', $author_url, $forum_id); }