function widget($args, $instance) { extract($args, EXTR_SKIP); $title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics'); $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; $orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness'; if ($orderby == 'newness') { $cb_meta_key = $cb_order_by = NULL; } elseif ($orderby == 'popular') { $cb_meta_key = '_bbp_reply_count'; $cb_order_by = 'meta_value'; } elseif ($orderby == 'freshness') { $cb_meta_key = '_bbp_last_active_time'; $cb_order_by = 'meta_value'; } if (!$number) { $number = 5; } $cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by)); echo $before_widget; echo $before_title . $title . $after_title; ?> <ul class="cb-bbp-recent-topics"> <?php while ($cb_qry->have_posts()) { $cb_qry->the_post(); ?> <li> <?php $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID); $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>'; $cb_number_replies = bbp_get_topic_reply_count($cb_reply_id); $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60)); $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name')); echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>'; ?> </li> <?php } ?> </ul> <?php echo $after_widget; // Reset the $post global wp_reset_postdata(); }
function widget($args, $instance) { extract($args, EXTR_SKIP); $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments'); $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $cb_qry = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true)); echo $before_widget; echo $before_title . $title . $after_title; ?> <ul class="cb-bbp-recent-replies"> <?php while ($cb_qry->have_posts()) { $cb_qry->the_post(); ?> <li> <?php $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID); $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>'; $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60)); $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name')); echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_reply_url . '<div class="cb-bbp-recent-replies-time">' . bbp_get_time_since(get_the_time('U')) . '</div></div>'; ?> </li> <?php } ?> </ul> <?php echo $after_widget; // Reset the $post global wp_reset_postdata(); }
/** * Output the topic title a reply belongs to * * @since bbPress (r2553) * * @param int $reply_id Optional. Reply id * @uses bbp_get_reply_topic_title() To get the reply topic title */ function bbp_reply_topic_title($reply_id = 0) { echo bbp_get_reply_topic_title($reply_id); }
/** * Displays the output, the replies list * * @since bbPress (r2653) * * @param mixed $args * @param array $instance * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title * @uses bbp_get_reply_author_link() To get the reply author link * @uses bbp_get_reply_author() To get the reply author name * @uses bbp_get_reply_id() To get the reply id * @uses bbp_get_reply_url() To get the reply url * @uses bbp_get_reply_excerpt() To get the reply excerpt * @uses bbp_get_reply_topic_title() To get the reply topic title * @uses get_the_date() To get the date of the reply * @uses get_the_time() To get the time of the reply */ public function widget($args, $instance) { extract($args); $title = apply_filters('bbp_replies_widget_title', $instance['title']); $max_shown = !empty($instance['max_shown']) ? $instance['max_shown'] : '5'; $show_date = !empty($instance['show_date']) ? 'on' : false; $show_user = !empty($instance['show_user']) ? 'on' : false; $post_types = !empty($instance['post_type']) ? array(bbp_get_topic_post_type(), bbp_get_reply_post_type()) : bbp_get_reply_post_type(); // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_exclude_forums filter and function. $widget_query = new WP_Query(array('post_type' => $post_types, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'posts_per_page' => $max_shown, 'meta_query' => array(bbp_exclude_forum_ids('meta_query')))); // Get replies and display them if ($widget_query->have_posts()) { echo $before_widget; echo $before_title . $title . $after_title; ?> <ul> <?php while ($widget_query->have_posts()) { $widget_query->the_post(); ?> <li> <?php $reply_id = bbp_get_reply_id($widget_query->post->ID); $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14)); $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . bbp_get_reply_excerpt($reply_id, 50) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>'; // Reply author, link, and timestamp if ('on' == $show_date && 'on' == $show_user) { // translators: 1: reply author, 2: reply link, 3: reply timestamp printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>'); // Reply link and timestamp } elseif ($show_date == 'on') { // translators: 1: reply link, 2: reply timestamp printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>'); // Reply author and title } elseif ($show_user == 'on') { // translators: 1: reply author, 2: reply link printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link); // Only the reply title } else { // translators: 1: reply link printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link); } ?> </li> <?php } ?> </ul> <?php echo $after_widget; // Reset the $post global wp_reset_postdata(); } }
/** * Displays the output, the replies list * * @since bbPress (r2653) * * @param mixed $args * @param array $instance * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title * @uses bbp_get_reply_author_link() To get the reply author link * @uses bbp_get_reply_id() To get the reply id * @uses bbp_get_reply_url() To get the reply url * @uses bbp_get_reply_excerpt() To get the reply excerpt * @uses bbp_get_reply_topic_title() To get the reply topic title * @uses get_the_date() To get the date of the reply * @uses get_the_time() To get the time of the reply */ public function widget($args, $instance) { // Get widget settings $settings = $this->parse_settings($instance); // Typical WordPress filter $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base); // bbPress filter $settings['title'] = apply_filters('bbp_replies_widget_title', $settings['title'], $instance, $this->id_base); // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_normalize_forum_visibility action and function. $widget_query = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => (int) $settings['max_shown'], 'ignore_sticky_posts' => true, 'no_found_rows' => true)); // Bail if no replies if (!$widget_query->have_posts()) { return; } echo $args['before_widget']; if (!empty($settings['title'])) { echo $args['before_title'] . $settings['title'] . $args['after_title']; } ?> <ul> <?php while ($widget_query->have_posts()) { $widget_query->the_post(); ?> <li> <?php // Verify the reply ID $reply_id = bbp_get_reply_id($widget_query->post->ID); $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($reply_id, 50)) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>'; // Only query user if showing them if (!empty($settings['show_user'])) { $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14)); } else { $author_link = false; } // Reply author, link, and timestamp if (!empty($settings['show_date']) && !empty($author_link)) { // translators: 1: reply author, 2: reply link, 3: reply timestamp printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>'); // Reply link and timestamp } elseif (!empty($settings['show_date'])) { // translators: 1: reply link, 2: reply timestamp printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>'); // Reply author and title } elseif (!empty($author_link)) { // translators: 1: reply author, 2: reply link printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link); // Only the reply title } else { // translators: 1: reply link printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link); } ?> </li> <?php } ?> </ul> <?php echo $args['after_widget']; // Reset the $post global wp_reset_postdata(); }
/** * @covers ::bbp_reply_topic_title * @covers ::bbp_get_reply_topic_title */ public function test_bbp_get_reply_topic_title() { $f = $this->factory->forum->create(); $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f))); $r = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t))); $reply_topic_title = bbp_get_reply_topic_title($r); $this->assertSame(bbp_get_topic_title($t), $reply_topic_title); }
/** * Displays the output, the replies list * * @since bbPress (r2653) * * @param mixed $args * @param array $instance * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title * @uses bbp_get_reply_author_link() To get the reply author link * @uses bbp_get_reply_author() To get the reply author name * @uses bbp_get_reply_id() To get the reply id * @uses bbp_get_reply_url() To get the reply url * @uses bbp_get_reply_excerpt() To get the reply excerpt * @uses bbp_get_reply_topic_title() To get the reply topic title * @uses get_the_date() To get the date of the reply * @uses get_the_time() To get the time of the reply */ public function widget($args, $instance) { // Get widget settings $settings = $this->parse_settings($instance); // Typical WordPress filter $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base); // bbPress filter $settings['title'] = apply_filters('pg_replies_widget_title', $settings['title'], $instance, $this->id_base); // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_exclude_forums filter and function. $query_data = array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => '50'); //PRIVATE GROUPS Get an array of IDs which the current user has permissions to view $allowed_posts = private_groups_get_permitted_post_ids(new WP_Query($query_data)); // The default forum query with allowed forum ids array added $query_data['post__in'] = $allowed_posts; //now set max posts $query_data['posts_per_page'] = (int) $settings['max_shown']; $widget_query = new WP_Query($query_data); // Bail if no replies if (!$widget_query->have_posts()) { return; } echo $args['before_widget']; if (!empty($settings['title'])) { echo $args['before_title'] . $settings['title'] . $args['after_title']; } ?> <ul> <?php while ($widget_query->have_posts()) { $widget_query->the_post(); ?> <li> <?php // Verify the reply ID $reply_id = bbp_get_reply_id($widget_query->post->ID); $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($reply_id, 50)) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>'; // Only query user if showing them if ('on' == $settings['show_user']) { $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14)); } else { $author_link = false; } // Reply author, link, and timestamp if ('on' == $settings['show_date'] && !empty($author_link)) { // translators: 1: reply author, 2: reply link, 3: reply timestamp printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>'); // Reply link and timestamp } elseif ('on' == $settings['show_date']) { // translators: 1: reply link, 2: reply timestamp printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>'); // Reply author and title } elseif (!empty($author_link)) { // translators: 1: reply author, 2: reply link printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link); // Only the reply title } else { // translators: 1: reply link printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link); } ?> </li> <?php } ?> </ul> <?php echo $args['after_widget']; // Reset the $post global wp_reset_postdata(); }
/** * Get the page context * @version 2.0 */ function get_context() { // Setup placeholders $title = SITENAME; $desc = get_bloginfo('description'); $classes = get_body_class(); $crumbs = array(); // Get some data $id = $this->queried_object_id; $object = $this->queried_object; $sep = " • "; /*-------------------------------------------- DEFAULT CONTEXT ---------------------------------------------*/ $classes[] = 0 == get_current_user_id() ? 'logged-out' : 'logged-in'; $crumbs[] = '<a href="' . SITEURL . '" title="' . SITENAME . '" rel="home" class="trail-home">Home</a>'; // Homepage if (is_home()) { $title = SITENAME . $sep . 'Home'; $classes[] = 'home'; $classes[] = 'sidebar'; $classes[] = 'archive'; /*-------------------------------------------- BUDDYPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('BuddyPress') && is_buddypress()) { // BuddyPress Defaults $title = "BuddyPress Page"; $desc = "This is a BuddyPress page."; $classes[] = 'buddypress'; // User Profiles if (bp_is_user()) { $title = bp_get_displayed_user_fullname() . $sep . "User Profile"; $desc = SITENAME . " user profile for member " . bp_get_displayed_user_fullname(); // Your own profile if (bp_is_my_profile()) { $crumbs[] = 'Your Profile'; } else { $crumbs[] = '<a href="' . bp_get_members_directory_permalink() . '" title="Members Directory">Members</a>'; $crumbs[] = '<a href="' . bp_displayed_user_domain() . '" title="' . bp_get_displayed_user_fullname() . '">' . bp_get_displayed_user_fullname() . '</a>'; } // Display the profile component if it isnt the profile home if (!bp_is_user_profile()) { $crumbs[] = ucfirst(bp_current_component()); } // Display the current action if it is not the default public profile if (!in_array(bp_current_action(), array('public', 'just-me', 'my-friends'))) { $crumbs[] = ucfirst(bp_current_action()); } // Single Group } elseif (bp_is_group() || bp_is_group_create()) { // Group Creation if (bp_is_group_create()) { $title = 'Submit New Group'; $desc = 'Submit a new user group for listing on the ' . SITENAME . ' community groups directory.'; $crumbs[] = '<a href="' . SITEURL . '/' . bp_get_groups_root_slug() . '" title="Groups Directory">Groups</a>'; $crumbs[] = 'Create Group'; } elseif (bp_is_group()) { // Default entries $title = bp_get_group_name(); $desc = SITENAME . ' guild profile for ' . bp_get_group_name(); $classes = array_diff($classes, array('page', 'page-template-default')); $crumbs[] = '<a href="' . bp_get_groups_directory_permalink() . '" title="Groups Directory">Groups</a>'; // Group Profile Home if (bp_is_group_home()) { $title = $title . $sep . 'Profile'; $crumbs[] = bp_get_group_name(); // Advanced Component } else { // Link back to group profile $crumbs[] = '<a href="' . bp_get_group_permalink() . '" title="Return to Group Profile">' . bp_get_group_name() . '</a>'; // Members if (bp_is_group_members()) { $title = $title . $sep . 'Members'; $crumbs[] = 'Members'; // Activity } elseif (bp_is_group_activity()) { $title = $title . $sep . 'Activity'; $crumbs[] = 'Activity'; // Invites } elseif (bp_is_group_invites()) { $title = $title . $sep . 'Invitations'; $crumbs[] = 'Invitations'; // Admin } elseif (bp_is_group_admin_page()) { $title = $title . $sep . 'Admin'; $crumbs[] = 'Admin'; // Forum } else { // Forum Root if (NULL == bp_action_variable()) { $title = $title . $sep . 'Forum'; $crumbs[] = 'Forum'; // Sub-Component } else { $crumbs[] = '<a href="' . bp_get_group_permalink() . 'forum/" title="Group Forum">Forum</a>'; // Retrieve topic information from the database global $bp; global $wpdb; // Single Topic if (bp_is_action_variable('topic', 0)) { // Get the topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; // Replies } elseif (bp_is_action_variable('reply', 0)) { // Get the reply parent topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE ID = ( \n\t\t\t\t\t\t\t\t\t\t\tSELECT post_parent\n\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts}\n\t\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s \n\t\t\t\t\t\t\t\t\t\t)", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; } // Topic and Reply Edits if (bp_is_action_variable('edit', 2)) { $crumbs[] = 'Edit'; } } } } } // Directories } elseif (bp_is_directory()) { // Sitewide Activity if (bp_is_activity_component()) { $title = SITENAME . ' Sitewide Activity Feed'; $desc = 'A listing of all recent activity happening throughout the ' . SITENAME . ' community.'; $crumbs[] = 'Sitewide Activity'; // Members Directory } elseif (bp_is_members_component()) { $title = SITENAME . ' Members Directory'; $desc = 'A listing of all registered members in the ' . SITENAME . ' community.'; $crumbs[] = 'Members Directory'; // Groups Directory } elseif (bp_is_groups_component()) { $title = SITENAME . ' Guilds Directory'; $desc = 'A directory listing of guilds active within in the ' . SITENAME . ' community.'; $crumbs[] = 'Guilds Directory'; } // Registration } elseif (bp_is_register_page()) { $title = SITENAME . ' User Registration'; $desc = "Register to join the " . SITENAME . " community."; $crumbs[] = "User Registration"; // Activation } elseif (bp_is_activation_page()) { $title = SITENAME . ' Account Activation'; $desc = "Activate a pending " . SITENAME . " user account."; $crumbs[] = "Account Activation"; } /*-------------------------------------------- BBPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('bbPress') && is_bbpress()) { // bbPress Defaults $classes[] = 'bbpress'; $classes[] = 'forums'; $crumbs[] = bbp_is_forum_archive() ? "Forums" : '<a href="' . get_post_type_archive_link('forum') . '">Forums</a>'; // Main Forum Archive if (bbp_is_forum_archive()) { $title = SITENAME . " Forums"; $desc = "Get involved in the community on the " . SITENAME . " forums."; // Recent Topics } elseif (bbp_is_topic_archive()) { $title = "Recent Topics in the " . SITENAME . " Forums"; $desc = "Browse a list of the most recent topics in the " . SITENAME . " Forums."; $crumbs[] = "Recent Topics"; // Single Forum } elseif (bbp_is_single_forum()) { $title = $object->post_title; $desc = $object->post_content; // Loop through parent forums $parent_id = bbp_get_forum_parent_id($id); if (0 != $parent_id) { $crumbs = array_merge($crumbs, $this->parent_crumbs($parent_id)); } $crumbs[] = $object->post_title; // Single Topic } elseif (bbp_is_single_topic()) { $title = $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_topic_forum_id($id))); $crumbs[] = $object->post_title; // Edit Topic } elseif (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) { $title = 'Edit Topic' . $sep . $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs($id)); // Tag the specific task if (bbp_is_topic_split()) { $crumbs[] = 'Split Topic'; } elseif (bbp_is_topic_merge()) { $crumbs[] = 'Merge Topic'; } elseif (bbp_is_topic_edit()) { $crumbs[] = 'Edit Topic'; } // Edit Reply } elseif (bbp_is_reply_edit()) { $title = 'Edit Reply' . $sep . bbp_get_reply_topic_title($id); $desc = bbp_get_reply_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_reply_topic_id($id))); $crumbs[] = 'Edit Reply'; } /*-------------------------------------------- WORDPRESS CONTEXT ---------------------------------------------*/ } else { // Singular Posts and Pages if (is_singular()) { $title = $object->post_title; $desc = get_post_meta($id, 'description', true); // If no description is found, use an excerpt if (empty($desc)) { $desc = get_post_field('post_excerpt', $id); } // Check for custom template $template = get_post_meta($id, "_wp_{$object->post_type}_template", true); if ('' != $template) { $template = str_replace(array("{$object->post_type}-template-", "{$object->post_type}-"), '', basename($template, '.php')); $classes[] = "{$template}-template"; } // Generate breadcrumbs by post type switch ($object->post_type) { // Single Posts case 'post': // Is the post in a category? $categories = get_the_category(); if ($categories) { // Start with the first category $term = $categories[0]; // If the category has a parent, add it to the trail. if (0 != $term->parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($term->parent, 'category')); } // Add the category archive link to the trail. $crumbs[] = '<a href="' . get_term_link($term) . '" title="' . esc_attr($term->name) . '">' . $term->name . '</a>'; } // Does the post have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Editing a comment on this post if (is_comment_edit()) { $crumbs[] = '<a href="' . get_permalink() . '" title="Return to article">' . get_the_title() . '</a>'; $crumbs[] = 'Edit Comment'; // Reading the post } else { $crumbs[] = get_the_title(); } break; // Pages // Pages case 'page': // Does the page have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Otherwise, viewing the page $crumbs[] = get_the_title(); break; // Events // Events case 'event': // Get the calendar the event belongs to $calendar = get_the_terms($object->ID, 'calendar'); $calendar = array_shift($calendar); $desc = 'Upcoming event on the ' . $calendar->name . ' calendar.'; $crumbs[] = '<a href="' . SITEURL . '/calendar/' . $calendar->slug . '" title="' . $calendar->name . ' Calendar">' . $calendar->name . ' Calendar</a>'; $crumbs[] = get_the_title(); break; } // Archives } elseif (is_archive()) { // Category Archives if (is_category()) { $crumbs[] = 'Category'; // If the category has a parent, add it to the trail. if ($object->parent != 0) { $crumbs = array_merge($crumbs, $this->trail_parents($object->parent)); } // Finish up with the term name $crumbs[] = $object->name; // Author Archive } elseif (is_author()) { $title = 'Author Archive' . $sep . $object->display_name; $desc = 'An archive of articles written by ' . $object->display_name; $crumbs[] = 'Author'; $crumbs[] = $object->display_name; // Advanced Search Page } elseif (is_search()) { $title = SITENAME . " Advanced Search"; $desc = "Search for a variety of content types throughout " . SITENAME; $crumbs[] = 'Advanced Search'; $classes[] = 'page'; // Calendar } elseif (is_calendar()) { $title = $object->name . " Calendar"; $desc = "Upcoming events on the " . $object->name . " calendar."; $crumbs[] = $object->name . " Calendar"; } // 404 } elseif (is_404()) { $title = "Error" . $sep . "Page Not Found"; $desc = "Sorry, but this page does not exist, or is not accessible at this time."; $classes[] = 'page'; $crumbs[] = '404 Page Not Found'; } } /*-------------------------------------------- RETURN DATA ---------------------------------------------*/ $this->title = html_entity_decode($title); $this->description = html_entity_decode($desc); $this->classes = $classes; $this->crumbs = $crumbs; }