function _bbps_wp_insert_post($post_ID, $post, $update)
{
    if ($post->post_status == 'publish' && $post->post_type == 'reply') {
        $check = get_post_meta($post_ID, 'support_hub', true);
        $forum_id = bbp_get_topic_forum_id($post->post_parent);
        //mail('*****@*****.**','WP Insert Post Done 2',var_export($post,true).var_export($check,true)."\n" . $forum_id);
        if ($check) {
            $data = @json_decode($check, true);
            if (!is_array($data)) {
                $data = array();
            }
            if (!isset($data['done']) || !$data['done']) {
                $data['done'] = true;
                update_post_meta($post_ID, 'support_hub', json_encode($data));
                // change the flag so we don't double process during this hook
                // run the usual bbpress hooks to update thread counts, send email replies and other stuff
                do_action('bbp_new_reply', $post_ID, $post->post_parent, $forum_id, 0, $post->post_author, false, 0);
                do_action('bbp_new_reply_post_extras', $post_ID);
                // todo: only set thread status to resolved if ticked in extra data above.
                if (isset($data['thread_resolved']) && $data['thread_resolved'] == 'resolved') {
                    update_post_meta($post->post_parent, '_bbps_topic_status', 2);
                    // update the thread status to resolved
                }
            }
        }
    }
}
function tehnik_filter_buddypress_activities($a, $activities)
{
    //if admin we want to know
    if (is_site_admin()) {
        return $activities;
    }
    foreach ($activities->activities as $key => $activity) {
        //new_member is the type name (component is 'profile')
        if ($activity->type == 'bbp_topic_create' || $activity->type == 'bbp_reply_create') {
            $post_id = $activity->secondary_item_id;
            if ($activity->type == 'bbp_reply_create') {
                $post_id = bbp_get_topic_forum_id($post_id);
            }
            if (!tehnik_bpp_can_user_view_post_id($post_id)) {
                unset($activities->activities[$key]);
                $activities->activity_count = $activities->activity_count - 1;
                $activities->total_activity_count = $activities->total_activity_count - 1;
                $activities->pag_num = $activities->pag_num - 1;
            }
        }
    }
    /* Renumber the array keys to account for missing items */
    $activities_new = array_values($activities->activities);
    $activities->activities = $activities_new;
    return $activities;
}
function bbps_is_topic_premium()
{
    $is_premium = get_post_meta(bbp_get_topic_forum_id(), '_bbps_is_premium');
    if ($is_premium[0] == 1) {
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 4
0
/**
 * Is this a premium topic?
 *
 * @since		1.0.0
 * @return		bool $return True if premium topic, false otherwise
 */
function edd_bbp_is_premium_topic()
{
    $is_premium = get_post_meta(bbp_get_topic_forum_id(), '_bbps_is_premium');
    if ($is_premium[0]) {
        $return = true;
    } else {
        $return = false;
    }
    return $return;
}
Ejemplo n.º 5
0
 /**
  * When inserting a new reply, make sure the protected meta data is set correctly.
  *
  * We can't use WP_JSON_Posts::add_meta() here because the required meta is deemed
  * protected by @see is_protected_meta().
  *
  * @see WP_JSON_Posts::insert_post()
  * @see WP_JSON_Posts::add_meta()
  */
 public function add_protected_meta($post, $data, $update)
 {
     if (!$update && $this->type == $post['post_type']) {
         // Forum meta
         $reply_meta = array('author_ip' => bbp_current_author_ip(), 'forum_id' => bbp_get_topic_forum_id($post['post_parent']), 'topic_id' => $post['post_parent']);
         // Insert reply meta
         foreach ($reply_meta as $meta_key => $meta_value) {
             update_post_meta($post['ID'], '_bbp_' . $meta_key, $meta_value);
         }
         // Update the topic
         $topic_id = bbp_get_reply_topic_id($post['ID']);
         if (!empty($topic_id)) {
             bbp_update_topic($topic_id);
         }
     }
 }
 /**
  * Verify access to the current content.
  *
  * @since  1.0.0
  *
  * @param int $id The content post ID to verify access.
  * @return bool|null True if has access, false otherwise.
  *     Null means: Rule not relevant for current page.
  */
 public function has_access($id, $admin_has_access = true)
 {
     global $wp_query;
     $has_access = null;
     if (empty($id)) {
         $id = $this->get_current_post_id();
     }
     if (!empty($id)) {
         $post_type = get_post_type($id);
         if (in_array($post_type, self::get_bb_cpt())) {
             $has_access = false;
             // Only verify permission if addon is enabled.
             if (MS_Addon_Bbpress::is_active()) {
                 switch ($post_type) {
                     case self::CPT_BB_FORUM:
                         $has_access = parent::has_access($id, $admin_has_access);
                         break;
                     case self::CPT_BB_TOPIC:
                         if (function_exists('bbp_get_topic_forum_id')) {
                             $forum_id = bbp_get_topic_forum_id($id);
                             $has_access = parent::has_access($forum_id, $admin_has_access);
                         }
                         break;
                     case self::CPT_BB_REPLY:
                         if (function_exists('bbp_get_reply_forum_id')) {
                             $forum_id = bbp_get_reply_forum_id($id);
                             $has_access = parent::has_access($forum_id, $admin_has_access);
                         }
                         break;
                 }
             } else {
                 $has_access = true;
             }
         }
     } else {
         /*
          * If post type is forum and no post_id, it is the forum list page, give access.
          * @todo Find another way to verify if the current page is the forum list page.
          */
         if (self::CPT_BB_FORUM === $wp_query->get('post_type')) {
             $has_access = true;
         }
     }
     return apply_filters('ms_addon_bbpress_model_rule_has_access', $has_access, $id, $this);
 }
Ejemplo n.º 7
0
 static function nav_menu_css_class($classes, $item, $args, $depth)
 {
     if ($item->object == bbp_get_forum_post_type() && is_bbpress()) {
         if (bbp_is_topic_edit() || bbp_is_single_topic()) {
             $forum_id = bbp_get_topic_forum_id();
             if ($forum_id == $item->object_id) {
                 $classes[] = 'current-menu-parent';
                 $classes[] = 'current-' . bbp_get_topic_post_type() . '-parent';
             } elseif ($ancestors = self::forum_ancestors($forum_id, array())) {
                 if (in_array($item->object_id, $ancestors)) {
                     $classes[] = 'current-menu-ancestor';
                     $classes[] = 'current-' . bbp_get_topic_post_type() . '-ancestor';
                 }
             }
         } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
             $forum_id = bbp_get_reply_forum_id();
         }
     }
     return $classes;
 }
function tehnik_bpp_get_forum_id_from_post_id($post_id, $post_type)
{
    $forum_id = 0;
    // Check post type
    switch ($post_type) {
        // Forum
        case bbp_get_forum_post_type():
            $forum_id = bbp_get_forum_id($post_id);
            break;
            // Topic
        // Topic
        case bbp_get_topic_post_type():
            $forum_id = bbp_get_topic_forum_id($post_id);
            break;
            // Reply
        // Reply
        case bbp_get_reply_post_type():
            $forum_id = bbp_get_reply_forum_id($post_id);
            break;
    }
    return $forum_id;
}
Ejemplo n.º 9
0
 /**
  * Print extra columns for the replies page
  *
  * @since 2.0.0 bbPress (r2577)
  *
  * @param string $column Column
  * @param int $reply_id reply id
  * @uses bbp_get_reply_topic_id() To get the topic id of the reply
  * @uses bbp_topic_title() To output the reply's topic title
  * @uses apply_filters() Calls 'reply_topic_row_actions' with an array
  *                        of reply topic actions
  * @uses bbp_get_topic_permalink() To get the topic permalink
  * @uses bbp_get_topic_forum_id() To get the forum id of the topic of
  *                                 the reply
  * @uses bbp_get_forum_permalink() To get the forum permalink
  * @uses admin_url() To get the admin url of post.php
  * @uses apply_filters() Calls 'reply_topic_forum_row_actions' with an
  *                        array of reply topic forum actions
  * @uses bbp_reply_author_display_name() To output the reply author name
  * @uses get_the_date() Get the reply creation date
  * @uses get_the_time() Get the reply creation time
  * @uses esc_attr() To sanitize the reply creation time
  * @uses bbp_get_reply_last_active_time() To get the time when the reply was
  *                                    last active
  * @uses do_action() Calls 'bbp_admin_replies_column_data' with the
  *                    column and reply id
  */
 public function column_data($column, $reply_id)
 {
     if ($this->bail()) {
         return;
     }
     // Get topic ID
     $topic_id = bbp_get_reply_topic_id($reply_id);
     // Populate Column Data
     switch ($column) {
         // Topic
         case 'bbp_reply_topic':
             // Output forum name
             if (!empty($topic_id)) {
                 // Topic Title
                 $topic_title = bbp_get_topic_title($topic_id);
                 if (empty($topic_title)) {
                     $topic_title = esc_html__('No Topic', 'bbpress');
                 }
                 // Output the title
                 echo $topic_title;
                 // Reply has no topic
             } else {
                 esc_html_e('No Topic', 'bbpress');
             }
             break;
             // Forum
         // Forum
         case 'bbp_reply_forum':
             // Get Forum ID's
             $reply_forum_id = bbp_get_reply_forum_id($reply_id);
             $topic_forum_id = bbp_get_topic_forum_id($topic_id);
             // Output forum name
             if (!empty($reply_forum_id)) {
                 // Forum Title
                 $forum_title = bbp_get_forum_title($reply_forum_id);
                 if (empty($forum_title)) {
                     $forum_title = esc_html__('No Forum', 'bbpress');
                 }
                 // Alert capable users of reply forum mismatch
                 if ($reply_forum_id !== $topic_forum_id) {
                     if (current_user_can('edit_others_replies') || current_user_can('moderate')) {
                         $forum_title .= '<div class="attention">' . esc_html__('(Mismatch)', 'bbpress') . '</div>';
                     }
                 }
                 // Output the title
                 echo $forum_title;
                 // Reply has no forum
             } else {
                 _e('No Forum', 'bbpress');
             }
             break;
             // Author
         // Author
         case 'bbp_reply_author':
             bbp_reply_author_display_name($reply_id);
             break;
             // Freshness
         // Freshness
         case 'bbp_reply_created':
             // Output last activity time and date
             printf('%1$s <br /> %2$s', get_the_date(), esc_attr(get_the_time()));
             break;
             // Do action for anything else
         // Do action for anything else
         default:
             do_action('bbp_admin_replies_column_data', $column, $reply_id);
             break;
     }
 }
Ejemplo n.º 10
0
/**
 * Unsticks a topic both from front and it's forum
 *
 * @since bbPress (r2754)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_topic_super_sticky() To check if the topic is a super sticky
 * @uses bbp_get_topic_forum_id() To get the topic forum id
 * @uses bbp_get_stickies() To get the forum stickies
 * @uses do_action() Calls 'bbp_unstick_topic' with the topic id
 * @uses delete_option() To delete the super stickies option
 * @uses update_option() To update the super stickies option
 * @uses delete_post_meta() To delete the forum stickies meta
 * @uses update_post_meta() To update the forum stickies meta
 * @uses do_action() Calls 'bbp_unsticked_topic' with the topic id and success
 * @return bool Always true.
 */
function bbp_unstick_topic($topic_id = 0)
{
    $topic_id = bbp_get_topic_id($topic_id);
    $super = bbp_is_topic_super_sticky($topic_id);
    $forum_id = empty($super) ? bbp_get_topic_forum_id($topic_id) : 0;
    $stickies = bbp_get_stickies($forum_id);
    $offset = array_search($topic_id, $stickies);
    do_action('bbp_unstick_topic', $topic_id);
    if (empty($stickies)) {
        $success = true;
    } elseif (!in_array($topic_id, $stickies)) {
        $success = true;
    } elseif (false === $offset) {
        $success = true;
    } else {
        array_splice($stickies, $offset, 1);
        if (empty($stickies)) {
            $success = !empty($super) ? delete_option('_bbp_super_sticky_topics') : delete_post_meta($forum_id, '_bbp_sticky_topics');
        } else {
            $success = !empty($super) ? update_option('_bbp_super_sticky_topics', $stickies) : update_post_meta($forum_id, '_bbp_sticky_topics', $stickies);
        }
    }
    do_action('bbp_unsticked_topic', $topic_id, $success);
    return (bool) $success;
}
Ejemplo n.º 11
0
/**
 * Return value of topic forum
 *
 * @since 2.0.0 bbPress (r2976)
 *
 * @uses bbp_is_topic_edit() To check if it's the topic edit page
 * @uses bbp_get_topic_forum_id() To get the topic forum id
 * @uses apply_filters() Calls 'bbp_get_form_topic_forum' with the forum
 * @return string Value of topic content field
 */
function bbp_get_form_topic_forum()
{
    // Get _POST data
    if (bbp_is_topic_form_post_request() && isset($_POST['bbp_forum_id'])) {
        $topic_forum = (int) $_POST['bbp_forum_id'];
        // Get edit data
    } elseif (bbp_is_topic_edit()) {
        $topic_forum = bbp_get_topic_forum_id();
        // No data
    } else {
        $topic_forum = 0;
    }
    return apply_filters('bbp_get_form_topic_forum', $topic_forum);
}
Ejemplo n.º 12
0
    ?>
</p>
		</div>
	</div>

<?php 
} elseif (bbp_is_forum_closed(bbp_get_topic_forum_id())) {
    ?>

	<div id="no-reply-<?php 
    bbp_topic_id();
    ?>
" class="bbp-no-reply">
		<div class="bbp-template-notice">
			<p><?php 
    printf(__('The forum &#8216;%s&#8217; is closed to new topics and replies.', 'bbpress'), bbp_get_forum_title(bbp_get_topic_forum_id()));
    ?>
</p>
		</div>
	</div>

<?php 
} else {
    ?>

	<div id="no-reply-<?php 
    bbp_topic_id();
    ?>
" class="bbp-no-reply">
		<div class="bbp-template-notice">
			<p><?php 
Ejemplo n.º 13
0
							<?php 
    if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'post__not_in' => array(bbp_get_topic_id())))) {
        ?>

								<div>
									<input name="bbp_topic_split_option" id="bbp_topic_split_option_existing" type="radio" value="existing" tabindex="<?php 
        bbp_tab_index();
        ?>
" />
									<label for="bbp_topic_split_option_existing"><?php 
        _e('Use an existing topic in this forum:', 'bbpress');
        ?>
</label>

									<?php 
        bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'selected' => -1, 'exclude' => bbp_get_topic_id(), 'select_id' => 'bbp_destination_topic', 'none_found' => __('No other topics found!', 'bbpress')));
        ?>

								</div>

							<?php 
    }
    ?>

						</fieldset>

						<fieldset class="bbp-form">
							<legend><?php 
    _e('Topic Extras', 'bbpress');
    ?>
</legend>
Ejemplo n.º 14
0
/**
 * Checks if a post (or any post type) has the given meta key of 'Stylesheet' when on the singular view of 
 * the post on the front of the site.  If found, the function checks within the '/css' folder of the stylesheet 
 * directory (child theme) and the template directory (parent theme).  If the file exists, it is used rather 
 * than the typical style.css file.
 *
 * @since 0.1.0
 * @todo Use features from Ticket #18302 when available. http://core.trac.wordpress.org/ticket/18302
 * @access public
 * @param string $stylesheet_uri The URI of the active theme's stylesheet.
 * @param string $stylesheet_dir_uri The directory URI of the active theme's stylesheet.
 * @return string $stylesheet_uri
 */
function post_stylesheets_stylesheet_uri($stylesheet_uri, $stylesheet_dir_uri)
{
    /* Check if viewing a singular post. */
    if (is_singular()) {
        /* If viewing a bbPress topic, use its forum object. */
        if (function_exists('bbp_is_single_topic') && bbp_is_single_topic()) {
            $post = get_post(bbp_get_topic_forum_id(get_queried_object_id()));
        } elseif (function_exists('bbp_is_single_reply') && bbp_is_single_reply()) {
            $post = get_post(bbp_get_reply_forum_id(get_queried_object_id()));
        } else {
            $post = get_queried_object();
        }
        /* Check if the post type supports 'post-stylesheets' before proceeding. */
        if (post_type_supports($post->post_type, 'post-stylesheets')) {
            /* Check if the user has set a value for the post stylesheet. */
            $stylesheet = get_post_stylesheet($post->ID);
            /* If a meta value was given and the file exists, set $stylesheet_uri to the new file. */
            if (!empty($stylesheet)) {
                /* If the stylesheet is found in the child theme, use it. */
                if (file_exists(trailingslashit(get_stylesheet_directory()) . $stylesheet)) {
                    $stylesheet_uri = trailingslashit($stylesheet_dir_uri) . $stylesheet;
                } elseif (file_exists(trailingslashit(get_template_directory()) . $stylesheet)) {
                    $stylesheet_uri = trailingslashit(get_template_directory_uri()) . $stylesheet;
                } else {
                    /* If the stylesheet is found in the child theme '/css' folder, use it. */
                    if (file_exists(trailingslashit(get_stylesheet_directory()) . "css/{$stylesheet}")) {
                        $stylesheet_uri = trailingslashit($stylesheet_dir_uri) . "css/{$stylesheet}";
                        /* Set the post stylesheet to the correct directory. */
                        set_post_stylesheet($post->ID, str_replace(get_stylesheet_directory_uri(), 'css/', $stylesheet_uri));
                    } elseif (file_exists(trailingslashit(get_template_directory()) . "css/{$stylesheet}")) {
                        $stylesheet_uri = trailingslashit(get_template_directory_uri()) . "css/{$stylesheet}";
                        /* Set the post stylesheet to the correct directory. */
                        set_post_stylesheet($post->ID, str_replace(get_template_directory_uri(), 'css/', $stylesheet_uri));
                    }
                }
            }
        }
    }
    /* Return the stylesheet URI. */
    return $stylesheet_uri;
}
Ejemplo n.º 15
0
 function cupid_breadcrumb_get_bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a></li>';
     }
     if (bbp_is_forum_archive()) {
         $item['last'] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item['last'] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item['last'] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a></li>';
         } else {
             $item['last'] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item['last'] = __('Split', 'cupid');
         } elseif (bbp_is_topic_merge()) {
             $item['last'] = __('Merge', 'cupid');
         } elseif (bbp_is_topic_edit()) {
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item['last'] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, cupid_breadcrumb_get_parents($forum_parent_id));
         }
         $item['last'] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         } else {
             $item['last'] = bbp_get_displayed_user_field('display_name');
         }
     }
     return apply_filters('cupid_breadcrumb_get_bbpress_items', $item);
 }
Ejemplo n.º 16
0
 function mk_theme_breadcrumbs()
 {
     global $mk_options, $post;
     $post_id = global_get_post_id();
     if ($post_id) {
         $local_skining = get_post_meta($post_id, '_enable_local_backgrounds', true);
         $breadcrumb_skin = get_post_meta($post_id, '_breadcrumb_skin', true);
         if ($local_skining == 'true' && !empty($breadcrumb_skin)) {
             $breadcrumb_skin_class = $breadcrumb_skin;
         } else {
             $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
         }
     } else {
         $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
     }
     $delimiter = ' &#47; ';
     echo '<div id="mk-breadcrumbs"><div class="mk-breadcrumbs-inner ' . $breadcrumb_skin_class . '-skin">';
     if (!is_front_page()) {
         echo '<a href="';
         echo home_url();
         echo '">' . __('Home', 'mk_framework');
         echo "</a>" . $delimiter;
     }
     if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
         $shop_page_id = wc_get_page_id('shop');
         $shop_page = get_post($shop_page_id);
         $permalinks = get_option('woocommerce_permalinks');
         if ($shop_page_id && $shop_page && get_option('page_on_front') !== $shop_page_id) {
             echo '<a href="' . get_permalink($shop_page) . '">' . $shop_page->post_title . '</a> ';
         }
     }
     if (is_category() && !is_singular('portfolio')) {
         $category = get_the_category();
         $ID = $category[0]->cat_ID;
         echo is_wp_error($cat_parents = get_category_parents($ID, TRUE, '', FALSE)) ? '' : '<span>' . $cat_parents . '</span>';
     } else {
         if (is_singular('news')) {
             echo '<span>' . get_the_title() . '</span>';
         } else {
             if (is_single() && !is_attachment()) {
                 if (get_post_type() == 'product') {
                     if ($terms = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent', 'order' => 'DESC'))) {
                         $main_term = $terms[0];
                         $ancestors = get_ancestors($main_term->term_id, 'product_cat');
                         $ancestors = array_reverse($ancestors);
                         foreach ($ancestors as $ancestor) {
                             $ancestor = get_term($ancestor, 'product_cat');
                             if (!is_wp_error($ancestor) && $ancestor) {
                                 echo '<a href="' . get_term_link($ancestor->slug, 'product_cat') . '">' . $ancestor->name . '</a>' . $delimiter;
                             }
                         }
                         echo '<a href="' . get_term_link($main_term->slug, 'product_cat') . '">' . $main_term->name . '</a>' . $delimiter;
                     }
                     echo get_the_title();
                 } elseif (is_singular('portfolio')) {
                     $portfolio_category = get_the_term_list($post->ID, 'portfolio_category', '', ' / ');
                     if (!empty($portfolio_category)) {
                         echo $portfolio_category . $delimiter;
                     }
                     echo '<span>' . get_the_title() . '</span>';
                 } elseif (get_post_type() != 'post') {
                     if (function_exists('is_bbpress') && is_bbpress()) {
                     } else {
                         $post_type = get_post_type_object(get_post_type());
                         $slug = $post_type->rewrite;
                         echo '<a href="' . get_post_type_archive_link(get_post_type()) . '">' . $post_type->labels->singular_name . '</a>' . $delimiter;
                         echo get_the_title();
                     }
                 } else {
                     $cat = current(get_the_category());
                     echo get_category_parents($cat, true, $delimiter);
                     echo get_the_title();
                 }
             } elseif (is_page() && !$post->post_parent) {
                 echo get_the_title();
             } elseif (is_page() && $post->post_parent) {
                 $parent_id = $post->post_parent;
                 $breadcrumbs = array();
                 while ($parent_id) {
                     $page = get_page($parent_id);
                     $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                     $parent_id = $page->post_parent;
                 }
                 $breadcrumbs = array_reverse($breadcrumbs);
                 foreach ($breadcrumbs as $crumb) {
                     echo $crumb . '' . $delimiter;
                 }
                 echo get_the_title();
             } elseif (is_attachment()) {
                 $parent = get_post($post->post_parent);
                 $cat = get_the_category($parent->ID);
                 $cat = $cat[0];
                 /* admin@innodron.com patch:
                 			   Fix for Catchable fatal error: Object of class WP_Error could not be converted to string
                 			   ref: https://wordpress.org/support/topic/catchable-fatal-error-object-of-class-wp_error-could-not-be-converted-to-string-11
                 			*/
                 echo is_wp_error($cat_parents = get_category_parents($cat, TRUE, '' . $delimiter . '')) ? '' : $cat_parents;
                 /* end admin@innodron.com patch */
                 echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $delimiter;
                 echo get_the_title();
             } elseif (is_search()) {
                 echo __('Search results for &ldquo;', 'mk_framework') . get_search_query() . '&rdquo;';
             } elseif (is_tag()) {
                 echo __('Tag &ldquo;', 'mk_framework') . single_tag_title('', false) . '&rdquo;';
             } elseif (is_author()) {
                 $userdata = get_userdata(get_the_author_meta('ID'));
                 echo __('Author:', 'mk_framework') . ' ' . $userdata->display_name;
             } elseif (is_day()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $delimiter;
                 echo get_the_time('d');
             } elseif (is_month()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo get_the_time('F');
             } elseif (is_year()) {
                 echo get_the_time('Y');
             }
         }
     }
     if (get_query_var('paged')) {
         echo ' (' . __('Page', 'mk_framework') . ' ' . get_query_var('paged') . ')';
     }
     if (is_tax()) {
         $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
         if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
             echo $delimiter;
         }
         echo '<span>' . $term->name . '</span>';
     }
     if (function_exists('is_bbpress') && is_bbpress()) {
         $item = array();
         $post_type_object = get_post_type_object(bbp_get_forum_post_type());
         if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
             $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
         }
         if (bbp_is_forum_archive()) {
             $item[] = bbp_get_forum_archive_title();
         } elseif (bbp_is_topic_archive()) {
             $item[] = bbp_get_topic_archive_title();
         } elseif (bbp_is_single_view()) {
             $item[] = bbp_get_view_title();
         } elseif (bbp_is_single_topic()) {
             $topic_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_topic_forum_id($topic_id)));
             if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
                 $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
             } else {
                 $item[] = bbp_get_topic_title($topic_id);
             }
             if (bbp_is_topic_split()) {
                 $item[] = __('Split', 'mk_framework');
             } elseif (bbp_is_topic_merge()) {
                 $item[] = __('Merge', 'mk_framework');
             } elseif (bbp_is_topic_edit()) {
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_reply()) {
             $reply_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_reply_topic_id($reply_id)));
             if (!bbp_is_reply_edit()) {
                 $item[] = bbp_get_reply_title($reply_id);
             } else {
                 $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_forum()) {
             $forum_id = get_queried_object_id();
             $forum_parent_id = bbp_get_forum_parent_id($forum_id);
             if (0 !== $forum_parent_id) {
                 $item = array_merge($item, mk_breadcrumbs_get_parents($forum_parent_id));
             }
             $item[] = bbp_get_forum_title($forum_id);
         } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
             if (bbp_is_single_user_edit()) {
                 $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             } else {
                 $item[] = bbp_get_displayed_user_field('display_name');
             }
         }
         echo implode($delimiter, $item);
     }
     echo "</div></div>";
 }
Ejemplo n.º 17
0
 protected function _bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<span typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '"  property="v:title" rel="v:url"><span>' . bbp_get_forum_archive_title() . '</span></a></span>';
     }
     if (bbp_is_forum_archive()) {
         $item[] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item[] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item[] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_topic_title($topic_id) . '</span></a></span>';
         } else {
             $item[] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item[] = __('Split', DH_DOMAIN);
         } elseif (bbp_is_topic_merge()) {
             $item[] = __('Merge', DH_DOMAIN);
         } elseif (bbp_is_topic_edit()) {
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item[] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_reply_title($reply_id) . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, $this->_get_parents($forum_parent_id));
         }
         $item[] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '"  property="v:title" rel="v:url" ><span>' . bbp_get_displayed_user_field('display_name') . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         } else {
             $item[] = bbp_get_displayed_user_field('display_name');
         }
     }
     return $item;
 }
Ejemplo n.º 18
0
 function hook_bbp_new_topic($topic_id)
 {
     $topic_url = bbp_get_topic_permalink($topic_id);
     //$dir = $this->get_folder() . '' . substr($topic_url, strlen(get_option('home'))) . '/';
     $dir = $this->get_folder() . '/' . substr($topic_url, strpos($topic_url, '://') + 3) . '/';
     $this->remove_dir($dir);
     $forum_id = bbp_get_topic_forum_id($topic_id);
     $forum_url = bbp_get_forum_permalink($forum_id);
     $dir = $this->get_folder() . '/' . substr($topic_url, strpos($forum_url, '://') + 3) . '/';
     //$dir = $this->get_folder() . '' . substr($forum_url, strlen(get_option('home'))) . '/';
     $this->remove_dir($dir);
 }
Ejemplo n.º 19
0
</span>

			<?php 
do_action('bbp_theme_after_topic_started_by');
?>

			<?php 
if (!bbp_is_single_forum() || bbp_get_topic_forum_id() !== bbp_get_forum_id()) {
    ?>

				<?php 
    do_action('bbp_theme_before_topic_started_in');
    ?>

				<span class="bbp-topic-started-in"><?php 
    printf(__('in: <a href="%1$s">%2$s</a>', 'bbpress'), bbp_get_forum_permalink(bbp_get_topic_forum_id()), bbp_get_forum_title(bbp_get_topic_forum_id()));
    ?>
</span>

				<?php 
    do_action('bbp_theme_after_topic_started_in');
    ?>

			<?php 
}
?>

		</p>

		<?php 
do_action('bbp_theme_after_topic_meta');
Ejemplo n.º 20
0
 /**
  * Update the activity stream entry when a topic status changes
  *
  * @param int $post_id
  * @param obj $post
  * @uses get_post_type()
  * @uses bbp_get_topic_post_type()
  * @uses bbp_get_topic_id()
  * @uses bbp_is_topic_anonymous()
  * @uses bbp_get_public_status_id()
  * @uses bbp_get_closed_status_id()
  * @uses bbp_get_topic_forum_id()
  * @uses bbp_get_topic_author_id()
  * @return Bail early if not a topic, or topic is by anonymous user
  */
 public function topic_update($topic_id, $post)
 {
     // Bail early if not a topic
     if (get_post_type($post) != bbp_get_topic_post_type()) {
         return;
     }
     $topic_id = bbp_get_topic_id($topic_id);
     // Bail early if topic is by anonymous user
     if (bbp_is_topic_anonymous($topic_id)) {
         return;
     }
     $anonymous_data = array();
     // Action based on new status
     if (in_array($post->post_status, array(bbp_get_public_status_id(), bbp_get_closed_status_id()))) {
         // Validate topic data
         $forum_id = bbp_get_topic_forum_id($topic_id);
         $topic_author_id = bbp_get_topic_author_id($topic_id);
         $this->topic_create($topic_id, $forum_id, $anonymous_data, $topic_author_id);
     } else {
         $this->topic_delete($topic_id);
     }
 }
Ejemplo n.º 21
0
<?php

/** Single topic meta */
?>


<div class="bbp-single-topic-meta">
	
	<div class="back-to">
		<a href="<?php 
echo bbp_get_forum_permalink();
?>
">&larr; Back to discussions</a>
	</div>


	<div class="posted-in">
		Posted in: <?php 
echo '<a href="' . bbp_get_forum_permalink() . '" class="parent-forum">' . bbp_get_forum_title(bbp_get_topic_forum_id()) . '</a>';
?>
 &nbsp;
	</div>
	
</div>
Ejemplo n.º 22
0
 /**
  * @covers ::bbp_update_topic_forum_id
  */
 public function test_bbp_update_topic_forum_id()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $forum_id = bbp_get_topic_forum_id($t);
     $this->assertSame($f, $forum_id);
     $topic_parent = wp_get_post_parent_id($t);
     $this->assertSame($f, $topic_parent);
     $this->assertTrue(delete_post_meta_by_key('_bbp_forum_id'));
     bbp_update_topic_forum_id($t, $f);
     $forum_id = bbp_get_topic_forum_id($t);
     $this->assertSame($f, $forum_id);
 }
Ejemplo n.º 23
0
/**
 * Repairs the relationship of sticky topics to the actual parent forum
 *
 * @since 2.3.0 bbPress (r4695)
 *
 * @uses wpdb::get_col() To run our recount sql queries
 * @uses is_wp_error() To check if the executed query returned {@link WP_Error}
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses get_post_meta() To get the sticky topics
 * @uses bbp_is_topic_super_sticky() To check if the topic is super sticky
 * @uses bbp_get_topic_forum_id() To get the topics forum id
 * @uses update_post_meta To update the topics sticky post meta
 * @return array An array of the status code and the message
 */
function bbp_admin_repair_sticky()
{
    // Define variables
    $bbp_db = bbp_db();
    $statement = __('Repairing the sticky topic to the parent forum relationships&hellip; %s', 'bbpress');
    $result = __('Failed!', 'bbpress');
    $forums = $bbp_db->get_col("SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "';");
    // Bail if no forums found
    if (empty($forums) || is_wp_error($forums)) {
        return array(1, sprintf($statement, $result));
    }
    // Loop through forums and get their sticky topics
    foreach ($forums as $forum) {
        $forum_stickies[$forum] = get_post_meta($forum, '_bbp_sticky_topics', true);
    }
    // Cleanup
    unset($forums, $forum);
    // Loop through each forum with sticky topics
    foreach ($forum_stickies as $forum_id => $stickies) {
        // Skip if no stickies
        if (empty($stickies)) {
            continue;
        }
        // Loop through each sticky topic
        foreach ($stickies as $id => $topic_id) {
            // If the topic is not a super sticky, and the forum ID does not
            // match the topic's forum ID, unset the forum's sticky meta.
            if (!bbp_is_topic_super_sticky($topic_id) && $forum_id !== bbp_get_topic_forum_id($topic_id)) {
                unset($forum_stickies[$forum_id][$id]);
            }
        }
        // Get sticky topic ID's, or use empty string
        $stickers = empty($forum_stickies[$forum_id]) ? '' : array_values($forum_stickies[$forum_id]);
        // Update the forum's sticky topics meta
        update_post_meta($forum_id, '_bbp_sticky_topics', $stickers);
    }
    // Complete results
    return array(0, sprintf($statement, __('Complete!', 'bbpress')));
}
Ejemplo n.º 24
0
              <legend><?php 
    _e('Destination', 'bbpress');
    ?>
</legend>
              <div>
                <?php 
    if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'post__not_in' => array(bbp_get_topic_id())))) {
        ?>

                  <label for="bbp_destination_topic"><?php 
        _e('Merge with this topic:', 'bbpress');
        ?>
</label>

                  <?php 
        bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'selected' => -1, 'exclude' => bbp_get_topic_id(), 'select_id' => 'bbp_destination_topic'));
        ?>

                <?php 
    } else {
        ?>

                  <label><?php 
        _e('There are no other topics in this forum to merge with.', 'bbpress');
        ?>
</label>

                <?php 
    }
    ?>
Ejemplo n.º 25
0
 /**
  * Runs through the various bbPress conditional tags to check the current page being viewed.  Once
  * a condition is met, add items to the $items array.
  *
  * @since  0.6.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();
     /* Get the forum post type object. */
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     /* If not viewing the forum root/archive page and a forum archive exists, add it. */
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $this->items[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
     }
     /* If viewing the forum root/archive. */
     if (bbp_is_forum_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_archive_title();
         }
     } elseif (bbp_is_topic_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_archive_title();
         }
     } elseif (bbp_is_topic_tag()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_tag_name();
         }
     } elseif (bbp_is_topic_tag_edit()) {
         $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
         if (true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_view()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_view_title();
         }
     } elseif (bbp_is_single_topic()) {
         /* Get the queried topic. */
         $topic_id = get_queried_object_id();
         /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
         $this->do_post_parents(bbp_get_topic_forum_id($topic_id));
         /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $this->items[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_title($topic_id);
         }
         /* If viewing a topic split page. */
         if (bbp_is_topic_split() && true === $this->args['show_title']) {
             $this->items[] = __('Split', 'breadcrumb-trail');
         } elseif (bbp_is_topic_merge() && true === $this->args['show_title']) {
             $this->items[] = __('Merge', 'breadcrumb-trail');
         } elseif (bbp_is_topic_edit() && true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_reply()) {
         /* Get the queried reply object ID. */
         $reply_id = get_queried_object_id();
         /* Get the parent items for the reply, which should be its topic. */
         $this->do_post_parents(bbp_get_reply_topic_id($reply_id));
         /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
         if (bbp_is_reply_edit()) {
             $this->items[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_reply_title($reply_id);
         }
     } elseif (bbp_is_single_forum()) {
         /* Get the queried forum ID and its parent forum ID. */
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         /* If the forum has a parent forum, get its parent(s). */
         if (0 !== $forum_parent_id) {
             $this->do_post_parents($forum_parent_id);
         }
         /* Add the forum title to the end of the trail. */
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_title($forum_id);
         }
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_displayed_user_field('display_name');
         }
     }
     /* Return the bbPress breadcrumb trail items. */
     $this->items = apply_filters('breadcrumb_trail_get_bbpress_items', $this->items, $this->args);
 }
Ejemplo n.º 26
0
/**
 * Check if it's a private forum or a topic or reply of a private forum and if
 * the user can't view it, then sets a 404
 *
 * @since bbPress (r2996)
 *
 * @uses current_user_can() To check if the current user can read private forums
 * @uses is_singular() To check if it's a singular page
 * @uses bbp_is_user_keymaster() To check if user is a keymaster
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() TO get the reply post type
 * @uses bbp_get_topic_forum_id() To get the topic forum id
 * @uses bbp_get_reply_forum_id() To get the reply forum id
 * @uses bbp_is_forum_private() To check if the forum is private or not
 * @uses bbp_set_404() To set a 404 status
 */
function bbp_forum_enforce_private()
{
    // Bail if not viewing a single item or if user has caps
    if (!is_singular() || bbp_is_user_keymaster() || current_user_can('read_private_forums')) {
        return;
    }
    global $wp_query;
    // Define local variable
    $forum_id = 0;
    // Check post type
    switch ($wp_query->get('post_type')) {
        // Forum
        case bbp_get_forum_post_type():
            $forum_id = bbp_get_forum_id($wp_query->post->ID);
            break;
            // Topic
        // Topic
        case bbp_get_topic_post_type():
            $forum_id = bbp_get_topic_forum_id($wp_query->post->ID);
            break;
            // Reply
        // Reply
        case bbp_get_reply_post_type():
            $forum_id = bbp_get_reply_forum_id($wp_query->post->ID);
            break;
    }
    // If forum is explicitly hidden and user not capable, set 404
    if (!empty($forum_id) && bbp_is_forum_private($forum_id) && !current_user_can('read_private_forums')) {
        bbp_set_404();
    }
}
    ?>
</p>
					</div>
					<h4><?php 
    _e('Destination', 'bbpress');
    ?>
</h4>
					<?php 
    if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'post__not_in' => array(bbp_get_topic_id())))) {
        ?>
						<label for="bbp_destination_topic"><?php 
        _e('Merge with this topic:', 'bbpress');
        ?>
</label>
						<?php 
        bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'selected' => -1, 'exclude' => bbp_get_topic_id(), 'select_id' => 'bbp_destination_topic', 'none_found' => __('No topics were found to which the topic could be merged to!', 'bbpress')));
        ?>
					<?php 
    } else {
        ?>
						<p class="alert alert-danger"><?php 
        _e('There are no other topics in this forum to merge with.', 'bbpress');
        ?>
</p>
					<?php 
    }
    ?>

					<h4><?php 
    _e('Topic Extras', 'bbpress');
    ?>
Ejemplo n.º 28
0
/**
 * Replace forum author details for users that cannot view them.
 *
 * @since bbPress (r3162)
 *
 * @param string $retval
 * @param int $forum_id
 *
 * @uses bbp_is_forum_private()
 * @uses get_post_field()
 * @uses bbp_get_topic_post_type()
 * @uses bbp_is_forum_private()
 * @uses bbp_get_topic_forum_id()
 * @uses bbp_get_reply_post_type()
 * @uses bbp_get_reply_forum_id()
 *
 * @return string
 */
function bbp_suppress_private_author_link($author_link, $args)
{
    // Assume the author link is the return value
    $retval = $author_link;
    // Show the normal author link
    if (!empty($args['post_id']) && !current_user_can('read_private_forums')) {
        // What post type are we looking at?
        $post_type = get_post_field('post_type', $args['post_id']);
        switch ($post_type) {
            // Topic
            case bbp_get_topic_post_type():
                if (bbp_is_forum_private(bbp_get_topic_forum_id($args['post_id']))) {
                    $retval = '';
                }
                break;
                // Reply
            // Reply
            case bbp_get_reply_post_type():
                if (bbp_is_forum_private(bbp_get_reply_forum_id($args['post_id']))) {
                    $retval = '';
                }
                break;
                // Post
            // Post
            default:
                if (bbp_is_forum_private($args['post_id'])) {
                    $retval = '';
                }
                break;
        }
    }
    return apply_filters('bbp_suppress_private_author_link', $retval);
}
Ejemplo n.º 29
0
    ?>
</p>
		</div>
	</div>

<?php 
} elseif (bbp_is_forum_closed(bbp_get_topic_forum_id())) {
    ?>

	<div id="no-reply-<?php 
    bbp_topic_id();
    ?>
" class="bbp-no-reply">
		<div class="bbp-template-notice">
			<p><?php 
    printf(esc_html__('The forum &#8216;%s&#8217; is closed to new topics and replies.', 'monsoon'), bbp_get_forum_title(bbp_get_topic_forum_id()));
    ?>
</p>
		</div>
	</div>

<?php 
} else {
    ?>

	<div id="no-reply-<?php 
    bbp_topic_id();
    ?>
" class="bbp-no-reply">
		<div class="bbp-template-notice">
			<p><?php 
Ejemplo n.º 30
0
/**
 * Output an RSS2 feed of replies, based on the query passed.
 *
 * @since bbPress (r3171)
 *
 * @uses bbp_version()
 * @uses bbp_is_single_topic()
 * @uses bbp_user_can_view_forum()
 * @uses bbp_get_topic_forum_id()
 * @uses bbp_show_load_topic()
 * @uses bbp_topic_permalink()
 * @uses bbp_topic_title()
 * @uses bbp_get_topic_reply_count()
 * @uses bbp_topic_content()
 * @uses bbp_has_replies()
 * @uses bbp_replies()
 * @uses bbp_the_reply()
 * @uses bbp_reply_url()
 * @uses bbp_reply_title()
 * @uses bbp_reply_content()
 * @uses get_wp_title_rss()
 * @uses get_option()
 * @uses bloginfo_rss
 * @uses self_link()
 * @uses the_author()
 * @uses get_post_time()
 * @uses rss_enclosure()
 * @uses do_action()
 * @uses apply_filters()
 *
 * @param array $replies_query
 */
function bbp_display_replies_feed_rss2($replies_query = array())
{
    // User cannot access forum this topic is in
    if (bbp_is_single_topic() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
        return;
    }
    // Adjust the title based on context
    if (bbp_is_single_topic() && bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
        $title = apply_filters('wp_title_rss', get_wp_title_rss(' &#187; '));
    } elseif (!bbp_show_lead_topic()) {
        $title = ' &#187; ' . __('All Posts', 'bbpress');
    } else {
        $title = ' &#187; ' . __('All Replies', 'bbpress');
    }
    // Display the feed
    header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
    header('Status: 200 OK');
    echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
    ?>

	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

		<?php 
    do_action('bbp_feed');
    ?>
	>

	<channel>
		<title><?php 
    bloginfo_rss('name');
    echo $title;
    ?>
</title>
		<atom:link href="<?php 
    self_link();
    ?>
" rel="self" type="application/rss+xml" />
		<link><?php 
    self_link();
    ?>
</link>
		<description><?php 
    //
    ?>
</description>
		<pubDate><?php 
    echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false);
    ?>
</pubDate>
		<generator>http://bbpress.org/?v=<?php 
    bbp_version();
    ?>
</generator>
		<language><?php 
    bloginfo_rss('language');
    ?>
</language>

		<?php 
    do_action('bbp_feed_head');
    ?>

		<?php 
    if (bbp_is_single_topic()) {
        ?>
			<?php 
        if (bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
            ?>
				<?php 
            if (bbp_show_lead_topic()) {
                ?>

					<item>
						<guid><?php 
                bbp_topic_permalink();
                ?>
</guid>
						<title><![CDATA[<?php 
                bbp_topic_title();
                ?>
]]></title>
						<link><?php 
                bbp_topic_permalink();
                ?>
</link>
						<pubDate><?php 
                echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);
                ?>
</pubDate>
						<dc:creator><?php 
                the_author();
                ?>
</dc:creator>

						<description>
							<![CDATA[
							<p><?php 
                printf(__('Replies: %s', 'bbpress'), bbp_get_topic_reply_count());
                ?>
</p>
							<?php 
                bbp_topic_content();
                ?>
							]]>
						</description>

						<?php 
                rss_enclosure();
                ?>

						<?php 
                do_action('bbp_feed_item');
                ?>

					</item>

				<?php 
            }
            ?>
			<?php 
        }
        ?>
		<?php 
    }
    ?>

		<?php 
    if (bbp_has_replies($replies_query)) {
        ?>
			<?php 
        while (bbp_replies()) {
            bbp_the_reply();
            ?>

				<item>
					<guid><?php 
            bbp_reply_url();
            ?>
</guid>
					<title><![CDATA[<?php 
            bbp_reply_title();
            ?>
]]></title>
					<link><?php 
            bbp_reply_url();
            ?>
</link>
					<pubDate><?php 
            echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);
            ?>
</pubDate>
					<dc:creator><?php 
            the_author();
            ?>
</dc:creator>

					<description>
						<![CDATA[
						<?php 
            bbp_reply_content();
            ?>
						]]>
					</description>

					<?php 
            rss_enclosure();
            ?>

					<?php 
            do_action('bbp_feed_item');
            ?>

				</item>

			<?php 
        }
        ?>
		<?php 
    }
    ?>

		<?php 
    do_action('bbp_feed_footer');
    ?>

	</channel>
	</rss>

<?php 
    // We're done here
    exit;
}