function bbPress_head_scripts()
    {
        // Put some scripts in the header, like AJAX url for wp-lists
        if (bbp_is_single_topic()) {
            ?>
	
		<script type='text/javascript'>
			/* <![CDATA[ */
			var ajaxurl = '<?php 
            echo admin_url('admin-ajax.php');
            ?>
';
			/* ]]> */
		</script>
	
		<?php 
        } elseif (bbp_is_single_user_edit()) {
            ?>
	
		<script type="text/javascript" charset="utf-8">
			if ( window.location.hash == '#password' ) {
				document.getElementById('pass1').focus();
			}
		</script>
	
		<?php 
        }
    }
        /**
         * Put some scripts in the header, like AJAX url for wp-lists
         *
         * @since bbPress (r2652)
         *
         * @uses bbp_is_single_topic() To check if it's the topic page
         * @uses admin_url() To get the admin url
         * @uses bbp_is_single_user_edit() To check if it's the profile edit page
         */
        function bbp_skeleton_scripts()
        {
            if (bbp_is_single_topic()) {
                ?>

	<script type='text/javascript'>
		/* <![CDATA[ */
		var ajaxurl = '<?php 
                echo admin_url('admin-ajax.php');
                ?>
';
		/* ]]> */
	</script>

	<?php 
            } elseif (bbp_is_single_user_edit()) {
                ?>

	<script type="text/javascript" charset="utf-8">
		if ( window.location.hash == '#password' ) {
			document.getElementById('pass1').focus();
		}
	</script>

	<?php 
            }
        }
/**
 * Possibly intercept the template being loaded
 *
 * Listens to the 'template_include' filter and waits for any bbPress specific
 * template condition to be met. If one is met and the template file exists,
 * it will be used; otherwise 
 *
 * Note that the _edit() checks are ahead of their counterparts, to prevent them
 * from being stomped on accident.
 *
 * @since bbPress (r3032)
 *
 * @param string $template
 *
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_search() To check if page is search
 * @uses bbp_get_search_template() To get search template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_move() To check if page is reply move
 * @uses bbp_get_reply_move_template() To get reply move template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 *
 * @return string The path to the template file that is being used
 */
function bbp_template_include_theme_supports($template = '')
{
    // Editing a user
    if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) {
        // User favorites
    } elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) {
        // User favorites
    } elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) {
        // Viewing a user
    } elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) {
        // Single View
    } elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) {
        // Search
    } elseif (bbp_is_search() && ($new_template = bbp_get_search_template())) {
        // Forum edit
    } elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) {
        // Single Forum
    } elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) {
        // Forum Archive
    } elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) {
        // Topic merge
    } elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) {
        // Topic split
    } elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) {
        // Topic edit
    } elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) {
        // Single Topic
    } elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) {
        // Topic Archive
    } elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) {
        // Reply move
    } elseif (bbp_is_reply_move() && ($new_template = bbp_get_reply_move_template())) {
        // Editing a reply
    } elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) {
        // Single Reply
    } elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) {
        // Editing a topic tag
    } elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) {
        // Viewing a topic tag
    } elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) {
    }
    // A bbPress template file was located, so override the WordPress template
    // and use it to switch off bbPress's theme compatibility.
    if (!empty($new_template)) {
        $template = bbp_set_template_included($new_template);
    }
    return apply_filters('bbp_template_include_theme_supports', $template);
}
Exemple #4
0
/**
 * Possibly intercept the template being loaded
 *
 * Listens to the 'template_include' filter and waits for any bbPress specific
 * template condition to be met. If one is met and the template file exists,
 * it will be used; otherwise 
 *
 * Note that the _edit() checks are ahead of their counterparts, to prevent them
 * from being stomped on accident.
 *
 * @since bbPress (r3032)
 *
 * @param string $template
 *
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 *
 * @return string The path to the template file that is being used
 */
function bbp_template_include_theme_supports($template = '')
{
    // Editing a user
    if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) {
        // User favorites
    } elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) {
        // User favorites
    } elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) {
        // Viewing a user
    } elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) {
        // Single View
    } elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) {
        // Forum edit
    } elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) {
        // Single Forum
    } elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) {
        // Forum Archive
    } elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) {
        // Topic merge
    } elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) {
        // Topic split
    } elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) {
        // Topic edit
    } elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) {
        // Single Topic
    } elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) {
        // Topic Archive
    } elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) {
        // Editing a reply
    } elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) {
        // Single Reply
    } elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) {
        // Editing a topic tag
    } elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) {
        // Viewing a topic tag
    } elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) {
    }
    // bbPress template file exists
    if (!empty($new_template)) {
        // Override the WordPress template with a bbPress one
        $template = $new_template;
        // @see: bbp_template_include_theme_compat()
        bbpress()->theme_compat->bbpress_template = true;
    }
    return apply_filters('bbp_template_include_theme_supports', $template);
}
Exemple #5
0
 function avia_bbpress_breadcrumb($trail)
 {
     global $avia_config;
     if (isset($avia_config['currently_viewing']) && $avia_config['currently_viewing'] == 'forum' || get_post_type() === "forum" || get_post_type() === "topic") {
         $bc = bbp_get_breadcrumb();
         if (isset($avia_config['bbpress_trail'])) {
             $trail_zero = $trail[0];
             $trail = $avia_config['bbpress_trail'];
             $trail[0] = $trail_zero;
         }
         if (bbp_is_single_user_edit() || bbp_is_single_user()) {
             $user_info = get_userdata(bbp_get_displayed_user_id());
             $title = __("Profile for User:"******"avia_framework") . " " . $user_info->display_name;
             array_pop($trail);
             $trail[] = $title;
         }
     }
     return $trail;
 }
 /**
  * Tweak problematic Genesis post actions
  *
  * @access private
  * @since 0.8
  */
 public function genesis_post_actions()
 {
     /**
      * If the current theme is a child theme of Genesis that also includes
      * the template files bbPress needs, we can leave things how they are.
      */
     if (is_bbpress()) {
         /** Remove Actions ************************************************/
         // Remove genesis breadcrumbs
         remove_action('genesis_before_loop', 'genesis_do_breadcrumbs');
         /**
          * Remove post info & meta
          * 
          * If you moved the info/meta from their default locations, you are
          * on your own.
          */
         remove_action('genesis_before_post_content', 'genesis_post_info');
         remove_action('genesis_after_post_content', 'genesis_post_meta');
         /**
          * Remove Genesis post image and content
          *
          * bbPress heavily relies on the_content() so if Genesis is
          * modifying it unexpectedly, we need to un-unexpect it.
          */
         remove_action('genesis_post_content', 'genesis_do_post_image');
         remove_action('genesis_post_content', 'genesis_do_post_content');
         /**
          * Remove authorbox
          * 
          * In some odd cases the Genesis authorbox could appear
          */
         remove_action('genesis_after_post', 'genesis_do_author_box_single');
         // Remove the navigation after the post loop
         remove_action('genesis_after_endwhile', 'genesis_posts_nav');
         // Remove post title from profile pages (as they don't work)
         if (bbp_is_single_user() || bbp_is_single_user_edit() || bbp_is_user_home()) {
             remove_action('genesis_post_title', 'genesis_do_post_title');
         }
         /** Add Actions ***************************************************/
         // Re add 'the_content' back onto 'genesis_post_content'
         add_action('genesis_post_content', 'the_content');
     }
 }
 /**
  * Enqueue the required Javascript files
  *
  * @since bbPress (r3732)
  *
  * @uses bbp_is_single_forum() To check if it's the forum page
  * @uses bbp_is_single_topic() To check if it's the topic page
  * @uses bbp_thread_replies() To check if threaded replies are enabled
  * @uses bbp_is_single_user_edit() To check if it's the profile edit page
  * @uses wp_enqueue_script() To enqueue the scripts
  */
 public function enqueue_scripts()
 {
     // Setup scripts array
     $scripts = array();
     // Always pull in jQuery for TinyMCE shortcode usage
     if (bbp_use_wp_editor()) {
         $scripts['bbpress-editor'] = array('file' => 'js/editor.js', 'dependencies' => array('jquery'));
     }
     // Forum-specific scripts
     if (bbp_is_single_forum()) {
         $scripts['bbpress-forum'] = array('file' => 'js/forum.js', 'dependencies' => array('jquery'));
     }
     // Topic-specific scripts
     if (bbp_is_single_topic()) {
         // Topic favorite/unsubscribe
         $scripts['bbpress-topic'] = array('file' => 'js/topic.js', 'dependencies' => array('jquery'));
         // Hierarchical replies
         if (bbp_thread_replies()) {
             $scripts['bbpress-reply'] = array('file' => 'js/reply.js', 'dependencies' => array('jquery'));
         }
     }
     // User Profile edit
     if (bbp_is_single_user_edit()) {
         $scripts['bbpress-user'] = array('file' => 'js/user.js', 'dependencies' => array('user-query'));
     }
     // Filter the scripts
     $scripts = apply_filters('bbp_default_scripts', $scripts);
     // Enqueue the scripts
     foreach ($scripts as $handle => $attributes) {
         bbp_enqueue_script($handle, $attributes['file'], $attributes['dependencies'], $this->version, 'screen');
     }
 }
Exemple #8
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>";
 }
Exemple #9
0
 function cb_bbp_author_details($cb_author_id, $cb_desc = true)
 {
     $cb_author_email = get_the_author_meta('publicemail', $cb_author_id);
     $cb_author_name = get_the_author_meta('display_name', $cb_author_id);
     $cb_author_position = get_the_author_meta('position', $cb_author_id);
     $cb_author_tw = get_the_author_meta('twitter', $cb_author_id);
     $cb_author_go = get_the_author_meta('googleplus', $cb_author_id);
     $cb_author_www = get_the_author_meta('url', $cb_author_id);
     $cb_author_desc = get_the_author_meta('description', $cb_author_id);
     $cb_author_posts = count_user_posts($cb_author_id);
     $cb_author_output = NULL;
     $cb_author_output .= '<div class="cb-author-details cb-bbp clearfix"><div class="cb-mask"><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '" rel="me">' . get_avatar(bbp_get_displayed_user_field('user_email', 'raw'), apply_filters('bbp_single_user_details_avatar_size', 150)) . '</a></div><div class="cb-meta"><h3><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '">' . $cb_author_name . '</a></h3>';
     if ($cb_author_position != NULL) {
         $cb_author_output .= '<div class="cb-author-position">' . $cb_author_position . '</div>';
     }
     if ($cb_author_desc != NULL && $cb_desc == true) {
         $cb_author_output .= '<p class="cb-author-bio">' . $cb_author_desc . '</p>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_tw != NULL || $cb_author_go != NULL) {
         $cb_author_output .= '<div class="cb-author-page-contact">';
     }
     if ($cb_author_email != NULL) {
         $cb_author_output .= '<a href="mailto:' . $cb_author_email . '"><i class="icon-envelope-alt cb-tip-bot" title="' . __('Email', 'cubell') . '"></i></a>';
     }
     if ($cb_author_www != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_www . '" target="_blank"><i class="icon-link cb-tip-bot" title="' . __('Website', 'cubell') . '"></i></a> ';
     }
     if ($cb_author_tw != NULL) {
         $cb_author_output .= ' <a href="//www.twitter.com/' . $cb_author_tw . '" target="_blank" ><i class="icon-twitter cb-tip-bot" title="Twitter"></i></a>';
     }
     if ($cb_author_go != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_go . '" rel="publisher" target="_top" title="Google+" class="cb-googleplus cb-tip-bot" ><img src="//ssl.gstatic.com/images/icons/gplus-32.png"  data-src-retina="//ssl.gstatic.com/images/icons/gplus-64.png" alt="Google+" ></a>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_go != NULL || $cb_author_tw != NULL) {
         $cb_author_output .= '</div>';
     }
     $cb_author_output .= '<div id="cb-user-nav"><ul>';
     if (bbp_is_single_user_replies()) {
         $cb_user_current = 'current';
     }
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_topics()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-topics-created-link"><a href="' . bbp_get_user_topics_created_url() . '">' . __('Topics Started', 'bbpress') . '</a></span></li>';
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_replies()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-replies-created-link"><a href="' . bbp_get_user_replies_created_url() . '">' . __('Replies Created', 'bbpress') . '</a></span></li>';
     if (bbp_is_favorites_active()) {
         $cb_author_output .= '<li class="';
         if (bbp_is_favorites()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-favorites-link"><a href="' . bbp_get_favorites_permalink() . '">' . __('Favorites', 'bbpress') . '</a></span></li>';
     }
     if (bbp_is_user_home() || current_user_can('edit_users')) {
         if (bbp_is_subscriptions_active()) {
             $cb_author_output .= '<li class="';
             if (bbp_is_subscriptions()) {
                 $cb_author_output .= 'current';
             }
             $cb_author_output .= '"><span class="bbp-user-subscriptions-link"><a href="' . bbp_get_subscriptions_permalink() . '">' . __('Subscriptions', 'bbpress') . '</a></span></li>';
         }
         $cb_author_output .= '<li class="';
         if (bbp_is_single_user_edit()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-edit-link"><a href="' . bbp_get_user_profile_edit_url() . '">' . __('Edit', 'bbpress') . '</a></span></li>';
     }
     $cb_author_output .= '</ul></div><!-- #cb-user-nav -->';
     $cb_author_output .= '</div></div>';
     return $cb_author_output;
 }
        ?>
" title="<?php 
        printf(esc_attr__("%s's Subscriptions", 'bbpress'), bbp_get_displayed_user_field('display_name'));
        ?>
"><?php 
        _e('Subscriptions', 'bbpress');
        ?>
</a>
							</span>
						</li>
					<?php 
    }
    ?>

					<li class="<?php 
    if (bbp_is_single_user_edit()) {
        ?>
current<?php 
    }
    ?>
">
						<span class="bbp-user-edit-link">
							<a href="<?php 
    bbp_user_profile_edit_url();
    ?>
" title="<?php 
    printf(esc_attr__("Edit %s's Profile", 'bbpress'), bbp_get_displayed_user_field('display_name'));
    ?>
"><?php 
    _e('Edit', 'bbpress');
    ?>
/**
 * Custom page title for bbPress pages
 *
 * @since bbPress (r2788)
 *
 * @param string $title Optional. The title (not used).
 * @param string $sep Optional, default is '&raquo;'. How to separate the
 *                     various items within the page title.
 * @param string $seplocation Optional. Direction to display title, 'right'.
 * @uses bbp_is_single_user() To check if it's a user profile page
 * @uses bbp_is_single_user_edit() To check if it's a user profile edit page
 * @uses bbp_is_user_home() To check if the profile page is of the current user
 * @uses get_query_var() To get the user id
 * @uses get_userdata() To get the user data
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_title() To get the forum title
 * @uses bbp_is_single_topic() To check if it's a topic
 * @uses bbp_get_topic_title() To get the topic title
 * @uses bbp_is_single_reply() To check if it's a reply
 * @uses bbp_get_reply_title() To get the reply title
 * @uses is_tax() To check if it's the tag page
 * @uses get_queried_object() To get the queried object
 * @uses bbp_is_single_view() To check if it's a view
 * @uses bbp_get_view_title() To get the view title
 * @uses apply_filters() Calls 'bbp_raw_title' with the title
 * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
 *                        separator and separator location
 * @return string The tite
 */
function bbp_title($title = '', $sep = '&raquo;', $seplocation = '')
{
    // Store original title to compare
    $_title = $title;
    /** Archives **************************************************************/
    // Forum Archive
    if (bbp_is_forum_archive()) {
        $title = bbp_get_forum_archive_title();
        // Topic Archive
    } elseif (bbp_is_topic_archive()) {
        $title = bbp_get_topic_archive_title();
        /** Singles ***************************************************************/
        // Forum page
    } elseif (bbp_is_single_forum()) {
        $title = sprintf(__('Forum: %s', 'bbpress'), bbp_get_forum_title());
        // Topic page
    } elseif (bbp_is_single_topic()) {
        $title = sprintf(__('Topic: %s', 'bbpress'), bbp_get_topic_title());
        // Replies
    } elseif (bbp_is_single_reply()) {
        $title = bbp_get_reply_title();
        // Topic tag page (or edit)
    } elseif (bbp_is_topic_tag() || bbp_is_topic_tag_edit() || get_query_var('bbp_topic_tag')) {
        $term = get_queried_object();
        $title = sprintf(__('Topic Tag: %s', 'bbpress'), $term->name);
        /** Users *****************************************************************/
        // Profile page
    } elseif (bbp_is_single_user()) {
        // Current users profile
        if (bbp_is_user_home()) {
            $title = __('Your Profile', 'bbpress');
            // Other users profile
        } else {
            $userdata = get_userdata(bbp_get_user_id());
            $title = sprintf(__('%s\'s Profile', 'bbpress'), $userdata->display_name);
        }
        // Profile edit page
    } elseif (bbp_is_single_user_edit()) {
        // Current users profile
        if (bbp_is_user_home_edit()) {
            $title = __('Edit Your Profile', 'bbpress');
            // Other users profile
        } else {
            $userdata = get_userdata(bbp_get_user_id());
            $title = sprintf(__('Edit %s\'s Profile', 'bbpress'), $userdata->display_name);
        }
        /** Views *****************************************************************/
        // Views
    } elseif (bbp_is_single_view()) {
        $title = sprintf(__('View: %s', 'bbpress'), bbp_get_view_title());
    }
    // Filter the raw title
    $title = apply_filters('bbp_raw_title', $title, $sep, $seplocation);
    // Compare new title with original title
    if ($title == $_title) {
        return $title;
    }
    // Temporary separator, for accurate flipping, if necessary
    $t_sep = '%WP_TITILE_SEP%';
    $prefix = '';
    if (!empty($title)) {
        $prefix = " {$sep} ";
    }
    // sep on right, so reverse the order
    if ('right' == $seplocation) {
        $title_array = explode($t_sep, $title);
        $title_array = array_reverse($title_array);
        $title = implode(" {$sep} ", $title_array) . $prefix;
        // sep on left, do not reverse
    } else {
        $title_array = explode($t_sep, $title);
        $title = $prefix . implode(" {$sep} ", $title_array);
    }
    // Filter and return
    return apply_filters('bbp_title', $title, $sep, $seplocation);
}
Exemple #12
0
/**
 * Replaces the_content() if the post_type being displayed is one that would
 * normally be handled by bbPress, but proper single page templates do not
 * exist in the currently active theme.
 *
 * Note that we do *not* currently use is_main_query() here. This is because so
 * many existing themes either use query_posts() or fail to use wp_reset_query()
 * when running queries before the main loop, causing theme compat to fail.
 *
 * @since bbPress (r3034)
 * @param string $content
 * @return type
 */
function bbp_replace_the_content($content = '')
{
    // Bail if not inside the query loop
    if (!in_the_loop()) {
        return $content;
    }
    $bbp = bbpress();
    // Define local variable(s)
    $new_content = '';
    // Bail if shortcodes are unset somehow
    if (!is_a($bbp->shortcodes, 'BBP_Shortcodes')) {
        return $content;
    }
    // Use shortcode API to display forums/topics/replies because they are
    // already output buffered and ready to fit inside the_content
    /** Users *************************************************************/
    // Profile View
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        ob_start();
        bbp_get_template_part('content', 'single-user');
        $new_content = ob_get_contents();
        ob_end_clean();
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_forum_index();
        }
        // Forum Edit
    } elseif (bbp_is_forum_edit()) {
        $new_content = $bbp->shortcodes->display_forum_form();
        // Single Forum
    } elseif (bbp_is_single_forum()) {
        $new_content = $bbp->shortcodes->display_forum(array('id' => get_the_ID()));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_topic_index();
        }
        // Topic Edit
    } elseif (bbp_is_topic_edit()) {
        // Split
        if (bbp_is_topic_split()) {
            ob_start();
            bbp_get_template_part('form', 'topic-split');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Merge
        } elseif (bbp_is_topic_merge()) {
            ob_start();
            bbp_get_template_part('form', 'topic-merge');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Edit
        } else {
            $new_content = $bbp->shortcodes->display_topic_form();
        }
        // Single Topic
    } elseif (bbp_is_single_topic()) {
        $new_content = $bbp->shortcodes->display_topic(array('id' => get_the_ID()));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        //$new_content = $bbp->shortcodes->display_reply_index();
        // Reply Edit
    } elseif (bbp_is_reply_edit()) {
        $new_content = $bbp->shortcodes->display_reply_form();
        // Single Reply
    } elseif (bbp_is_single_reply()) {
        $new_content = $bbp->shortcodes->display_reply(array('id' => get_the_ID()));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        $new_content = $bbp->shortcodes->display_view(array('id' => get_query_var('bbp_view')));
        /** Topic Tags ********************************************************/
        // Show topics of tag
    } elseif (bbp_is_topic_tag()) {
        $new_content = $bbp->shortcodes->display_topics_of_tag(array('id' => bbp_get_topic_tag_id()));
        // Edit topic tag
    } elseif (bbp_is_topic_tag_edit()) {
        $new_content = $bbp->shortcodes->display_topic_tag_form();
    }
    // Juggle the content around and try to prevent unsightly comments
    if (!empty($new_content) && $new_content != $content) {
        // Set the content to be the new content
        $content = apply_filters('bbp_replace_the_content', $new_content, $content);
        // Clean up after ourselves
        unset($new_content);
        // Reset the $post global
        wp_reset_postdata();
    }
    // Return possibly hi-jacked content
    return $content;
}
Exemple #13
0
/**
 * Custom page title for bbPress pages
 *
 * @since bbPress (r2788)
 *
 * @param string $title Optional. The title (not used).
 * @param string $sep Optional, default is '&raquo;'. How to separate the
 *                     various items within the page title.
 * @param string $seplocation Optional. Direction to display title, 'right'.
 * @uses bbp_is_single_user() To check if it's a user profile page
 * @uses bbp_is_single_user_edit() To check if it's a user profile edit page
 * @uses bbp_is_user_home() To check if the profile page is of the current user
 * @uses get_query_var() To get the user id
 * @uses get_userdata() To get the user data
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_title() To get the forum title
 * @uses bbp_is_single_topic() To check if it's a topic
 * @uses bbp_get_topic_title() To get the topic title
 * @uses bbp_is_single_reply() To check if it's a reply
 * @uses bbp_get_reply_title() To get the reply title
 * @uses is_tax() To check if it's the tag page
 * @uses get_queried_object() To get the queried object
 * @uses bbp_is_single_view() To check if it's a view
 * @uses bbp_get_view_title() To get the view title
 * @uses apply_filters() Calls 'bbp_raw_title' with the title
 * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
 *                        separator and separator location
 * @return string The tite
 */
function bbp_title($title = '', $sep = '&raquo;', $seplocation = '')
{
    // Title array
    $new_title = array();
    /** Archives **************************************************************/
    // Forum Archive
    if (bbp_is_forum_archive()) {
        $new_title['text'] = bbp_get_forum_archive_title();
        // Topic Archive
    } elseif (bbp_is_topic_archive()) {
        $new_title['text'] = bbp_get_topic_archive_title();
        /** Edit ******************************************************************/
        // Forum edit page
    } elseif (bbp_is_forum_edit()) {
        $new_title['text'] = bbp_get_forum_title();
        $new_title['format'] = esc_attr__('Forum Edit: %s', 'bbpress');
        // Topic edit page
    } elseif (bbp_is_topic_edit()) {
        $new_title['text'] = bbp_get_topic_title();
        $new_title['format'] = esc_attr__('Topic Edit: %s', 'bbpress');
        // Reply edit page
    } elseif (bbp_is_reply_edit()) {
        $new_title['text'] = bbp_get_reply_title();
        $new_title['format'] = esc_attr__('Reply Edit: %s', 'bbpress');
        // Topic tag edit page
    } elseif (bbp_is_topic_tag_edit()) {
        $new_title['text'] = bbp_get_topic_tag_name();
        $new_title['format'] = esc_attr__('Topic Tag Edit: %s', 'bbpress');
        /** Singles ***************************************************************/
        // Forum page
    } elseif (bbp_is_single_forum()) {
        $new_title['text'] = bbp_get_forum_title();
        $new_title['format'] = esc_attr__('Forum: %s', 'bbpress');
        // Topic page
    } elseif (bbp_is_single_topic()) {
        $new_title['text'] = bbp_get_topic_title();
        $new_title['format'] = esc_attr__('Topic: %s', 'bbpress');
        // Replies
    } elseif (bbp_is_single_reply()) {
        $new_title['text'] = bbp_get_reply_title();
        // Topic tag page
    } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag')) {
        $new_title['text'] = bbp_get_topic_tag_name();
        $new_title['format'] = esc_attr__('Topic Tag: %s', 'bbpress');
        /** Users *****************************************************************/
        // Profile page
    } elseif (bbp_is_single_user()) {
        // User is viewing their own profile
        if (bbp_is_user_home()) {
            $new_title['text'] = esc_attr_x('Your', 'User viewing his/her own profile', 'bbpress');
            // User is viewing someone else's profile (so use their display name)
        } else {
            $new_title['text'] = sprintf(esc_attr_x("%s's", 'User viewing another users profile', 'bbpress'), get_userdata(bbp_get_user_id())->display_name);
        }
        // User topics created
        if (bbp_is_single_user_topics()) {
            $new_title['format'] = esc_attr__("%s Topics", 'bbpress');
            // User rueplies created
        } elseif (bbp_is_single_user_replies()) {
            $new_title['format'] = esc_attr__("%s Replies", 'bbpress');
            // User favorites
        } elseif (bbp_is_favorites()) {
            $new_title['format'] = esc_attr__("%s Favorites", 'bbpress');
            // User subscriptions
        } elseif (bbp_is_subscriptions()) {
            $new_title['format'] = esc_attr__("%s Subscriptions", 'bbpress');
            // User "home"
        } else {
            $new_title['format'] = esc_attr__("%s Profile", 'bbpress');
        }
        // Profile edit page
    } elseif (bbp_is_single_user_edit()) {
        // Current user
        if (bbp_is_user_home_edit()) {
            $new_title['text'] = esc_attr__('Edit Your Profile', 'bbpress');
            // Other user
        } else {
            $new_title['text'] = get_userdata(bbp_get_user_id())->display_name;
            $new_title['format'] = esc_attr__("Edit %s's Profile", 'bbpress');
        }
        /** Views *****************************************************************/
        // Views
    } elseif (bbp_is_single_view()) {
        $new_title['text'] = bbp_get_view_title();
        $new_title['format'] = esc_attr__('View: %s', 'bbpress');
        /** Search ****************************************************************/
        // Search
    } elseif (bbp_is_search()) {
        $new_title['text'] = bbp_get_search_title();
    }
    // This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
    $new_title = apply_filters('bbp_raw_title_array', $new_title);
    // Set title array defaults
    $new_title = bbp_parse_args($new_title, array('text' => $title, 'format' => '%s'), 'title');
    // Get the formatted raw title
    $new_title = sprintf($new_title['format'], $new_title['text']);
    // Filter the raw title
    $new_title = apply_filters('bbp_raw_title', $new_title, $sep, $seplocation);
    // Compare new title with original title
    if ($new_title === $title) {
        return $title;
    }
    // Temporary separator, for accurate flipping, if necessary
    $t_sep = '%WP_TITILE_SEP%';
    $prefix = '';
    if (!empty($new_title)) {
        $prefix = " {$sep} ";
    }
    // sep on right, so reverse the order
    if ('right' === $seplocation) {
        $new_title_array = array_reverse(explode($t_sep, $new_title));
        $new_title = implode(" {$sep} ", $new_title_array) . $prefix;
        // sep on left, do not reverse
    } else {
        $new_title_array = explode($t_sep, $new_title);
        $new_title = $prefix . implode(" {$sep} ", $new_title_array);
    }
    // Filter and return
    return apply_filters('bbp_title', $new_title, $sep, $seplocation);
}
        /**
         * Put some scripts in the header, like AJAX url for wp-lists
         *
         * @since bbPress (r3732)
         *
         * @uses bbp_is_single_topic() To check if it's the topic page
         * @uses admin_url() To get the admin url
         * @uses bbp_is_single_user_edit() To check if it's the profile edit page
         */
        public function head_scripts()
        {
            ?>

		<script type="text/javascript">
			/* <![CDATA[ */
			var ajaxurl = '<?php 
            echo admin_url('admin-ajax.php');
            ?>
';

			<?php 
            if (bbp_is_single_user_edit()) {
                ?>
			if ( window.location.hash == '#password' ) {
				document.getElementById('pass1').focus();
			}
			<?php 
            }
            ?>
			/* ]]> */
		</script>

	<?php 
        }
        /**
         * Put some scripts in the header, like AJAX url for wp-lists
         *
         * @since bbPress (r3732)
         *
         * @uses bbp_is_single_topic() To check if it's the topic page
         * @uses admin_url() To get the admin url
         * @uses bbp_is_single_user_edit() To check if it's the profile edit page
         */
        public function head_scripts()
        {
            // Bail if no extra JS is needed
            if (!bbp_is_single_user_edit() && !bbp_use_wp_editor()) {
                return;
            }
            ?>

		<script type="text/javascript">
			/* <![CDATA[ */
			<?php 
            if (bbp_is_single_user_edit()) {
                ?>
			if ( window.location.hash === '#password' ) {
				document.getElementById('pass1').focus();
			}
			<?php 
            }
            ?>

			<?php 
            if (bbp_use_wp_editor()) {
                ?>
			jQuery(document).ready( function() {

				/* Use backticks instead of <code> for the Code button in the editor */
				if ( typeof( edButtons ) !== 'undefined' ) {
					edButtons[110] = new QTags.TagButton( 'code', 'code', '`', '`', 'c' );
					QTags._buttonsInit();
				}

				/* Tab from topic title */
				jQuery( '#bbp_topic_title' ).bind( 'keydown.editor-focus', function(e) {
					if ( e.which !== 9 )
						return;

					if ( !e.ctrlKey && !e.altKey && !e.shiftKey ) {
						if ( typeof( tinymce ) !== 'undefined' ) {
							if ( ! tinymce.activeEditor.isHidden() ) {
								var editor = tinymce.activeEditor.editorContainer;
								jQuery( '#' + editor + ' td.mceToolbar > a' ).focus();
							} else {
								jQuery( 'textarea.bbp-the-content' ).focus();
							}
						} else {
							jQuery( 'textarea.bbp-the-content' ).focus();
						}

						e.preventDefault();
					}
				});

				/* Shift + tab from topic tags */
				jQuery( '#bbp_topic_tags' ).bind( 'keydown.editor-focus', function(e) {
					if ( e.which !== 9 )
						return;

					if ( e.shiftKey && !e.ctrlKey && !e.altKey ) {
						if ( typeof( tinymce ) !== 'undefined' ) {
							if ( ! tinymce.activeEditor.isHidden() ) {
								var editor = tinymce.activeEditor.editorContainer;
								jQuery( '#' + editor + ' td.mceToolbar > a' ).focus();
							} else {
								jQuery( 'textarea.bbp-the-content' ).focus();
							}
						} else {
							jQuery( 'textarea.bbp-the-content' ).focus();
						}

						e.preventDefault();
					}
				});
			});
			<?php 
            }
            ?>
			/* ]]> */
		</script>

	<?php 
        }
function uni_avatar_scripts()
{
    wp_enqueue_script('jquery');
    if (get_option('uni_upload_form_in_front')) {
        wp_enqueue_media();
    }
    if (function_exists('bp_is_active')) {
        if (bp_is_profile_component() && 'change-avatar' == bp_current_action() && get_option('uni_avatar_enable_buddypress_form_override')) {
            wp_enqueue_media();
        }
    }
    if (class_exists('bbPress')) {
        if (bbp_is_single_user_edit()) {
            wp_enqueue_media();
        }
    }
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-widget');
    wp_enqueue_script('jcrop');
    wp_register_script('jquery.iframe-transport', UNI_AVATAR_WP_PLUGIN_URL . 'js/jquery.iframe-transport.js', array('jquery-ui-widget'), '1.8.3');
    wp_enqueue_script('jquery.iframe-transport');
    wp_register_script('jquery.fileupload', UNI_AVATAR_WP_PLUGIN_URL . 'js/jquery.fileupload.js', array('jquery-ui-widget'), '5.42.3');
    wp_enqueue_script('jquery.fileupload');
    wp_register_script('jquery.fileupload-process', UNI_AVATAR_WP_PLUGIN_URL . 'js/jquery.fileupload-process.js', array('jquery-ui-widget'), '5.42.3');
    wp_enqueue_script('jquery.fileupload-process');
    wp_register_script('jquery.fileupload-validate', UNI_AVATAR_WP_PLUGIN_URL . 'js/jquery.fileupload-validate.js', array('jquery-ui-widget'), '5.42.3');
    wp_enqueue_script('jquery.fileupload-validate');
    wp_register_script('uni-avatar-modal', UNI_AVATAR_WP_PLUGIN_URL . 'js/uni-avatar-modal.js', array('jquery.fileupload'), UNI_AVATAR_VERSION);
    wp_enqueue_script('uni-avatar-modal');
    $params = array('site_url' => get_bloginfo('url'), 'ajax_url' => admin_url('admin-ajax.php'), 'upload_form_in_front_on' => get_option('uni_upload_form_in_front') || function_exists('bp_is_active') && get_option('uni_avatar_enable_buddypress_form_override') && bp_is_profile_component() && 'change-avatar' == bp_current_action() || class_exists('bbPress') && bbp_is_single_user_edit() ? 1 : 0, 'select_avatars_on' => get_option('uni_avatar_custom_avatars') ? 1 : 0, 'uni_avatar_max' => get_option('uni_avatar_default_size') ? get_option('uni_avatar_default_size') * 1024 : UNI_AVATAR_DEFAULT_SIZE * 1024, 'modal_upload_title' => __('Upload Avatar', 'uni-avatar'), 'modal_select_title' => __('Select Avatar', 'uni-avatar'), 'file_not_allowed' => __('File type not allowed', 'uni-avatar'), 'file_too_large' => __('File is too large', 'uni-avatar'));
    wp_localize_script('uni-avatar-modal', 'uniavatarparams', $params);
    wp_enqueue_style('dashicons');
    wp_enqueue_style('admin-css', UNI_AVATAR_WP_PLUGIN_URL . 'css/uniavatar-styles-front.css');
}
 /**
  * dynWid::detectPage() Page detection
  *
  * @return string
  */
 public function detectPage()
 {
     // First we register the Path URL
     $this->url = $_SERVER['REQUEST_URI'];
     if (is_front_page() && get_option('show_on_front') == 'posts') {
         return 'front-page';
     } else {
         if (is_home() && get_option('show_on_front') == 'page') {
             return 'front-page';
         } else {
             if (is_attachment()) {
                 return 'attachment';
                 // must be before is_single(), otherwise detects as 'single'
             } else {
                 if (is_single()) {
                     return 'single';
                 } else {
                     if (is_page()) {
                         return 'page';
                     } else {
                         if (is_author()) {
                             return 'author';
                         } else {
                             if (is_category()) {
                                 return 'category';
                             } else {
                                 if (is_tag()) {
                                     return 'tag';
                                 } else {
                                     if (function_exists('is_post_type_archive') && is_post_type_archive()) {
                                         return 'cp_archive';
                                         // must be before is_archive(), otherwise detects as 'archive' in WP 3.1.0
                                     } else {
                                         if (function_exists('is_tax') && is_tax()) {
                                             return 'tax_archive';
                                         } else {
                                             if (is_archive() && !is_category() && !is_author() && !is_tag()) {
                                                 return 'archive';
                                             } else {
                                                 if (function_exists('bbp_is_single_user') && (bbp_is_single_user() || bbp_is_single_user_edit())) {
                                                     // must be before is_404(), otherwise bbPress profile page is detected as 'e404'.
                                                     return 'bbp_profile';
                                                 } else {
                                                     if (is_404()) {
                                                         return 'e404';
                                                     } else {
                                                         if (is_search()) {
                                                             return 'search';
                                                         } else {
                                                             if (function_exists('is_pod_page') && is_pod_page()) {
                                                                 return 'pods';
                                                             } else {
                                                                 return 'undef';
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #18
0
/**
 * Super admin privileges notice
 *
 * @since bbPress (r2688)
 *
 * @uses is_multisite() To check if the blog is multisite
 * @uses bbp_is_single_user() To check if it's the profile page
 * @uses bbp_is_single_user_edit() To check if it's the profile edit page
 * @uses current_user_can() To check if the current user can manage network
 *                           options
 * @uses bbp_get_displayed_user_id() To get the displayed user id
 * @uses is_super_admin() To check if the user is super admin
 * @uses bbp_is_user_home() To check if it's the user home
 * @uses bbp_is_user_home_edit() To check if it's the user home edit
 */
function bbp_notice_edit_user_is_super_admin()
{
    if (is_multisite() && (bbp_is_single_user() || bbp_is_single_user_edit()) && current_user_can('manage_network_options') && is_super_admin(bbp_get_displayed_user_id())) {
        ?>

	<div class="bbp-template-notice important">
		<p><?php 
        bbp_is_user_home() || bbp_is_user_home_edit() ? _e('You have super admin privileges.', 'bbpress') : _e('This user has super admin privileges.', 'bbpress');
        ?>
</p>
	</div>

<?php 
    }
}
Exemple #19
0
/**
 * Reset main query vars and filter 'the_content' to output a bbPress
 * template part as needed.
 *
 * @since 2.0.0 bbPress (r3032)
 *
 * @param string $template
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_search() To check if page is search
 * @uses bbp_get_search_template() To get search template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_move() To check if page is reply move
 * @uses bbp_get_reply_move_template() To get reply move template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 */
function bbp_template_include_theme_compat($template = '')
{
    /**
     * Bail if a root template was already found. This prevents unintended
     * recursive filtering of 'the_content'.
     *
     * @link https://bbpress.trac.wordpress.org/ticket/2429
     */
    if (bbp_is_template_included()) {
        return $template;
    }
    /**
     * If BuddyPress is activated at a network level, the action order is
     * reversed, which causes the template integration to fail. If we're looking
     * at a BuddyPress page here, bail to prevent the extra processing.
     *
     * This is a bit more brute-force than is probably necessary, but gets the
     * job done while we work towards something more elegant.
     */
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $template;
    }
    // Define local variable(s)
    $bbp_shortcodes = bbpress()->shortcodes;
    // Bail if shortcodes are unset somehow
    if (!is_a($bbp_shortcodes, 'BBP_Shortcodes')) {
        return $template;
    }
    /** Users *************************************************************/
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => bbp_buffer_template_part('content', 'single-user', false), 'post_type' => '', 'post_title' => bbp_get_displayed_user_field('display_name'), 'post_status' => bbp_get_public_status_id(), 'is_single' => true, 'is_archive' => false, 'comment_status' => 'closed'));
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        // Should we replace the content...
        if (empty($page->post_content)) {
            // Use the topics archive
            if ('topics' === bbp_show_on_root()) {
                $new_content = $bbp_shortcodes->display_topic_index();
                // No page so show the archive
            } else {
                $new_content = $bbp_shortcodes->display_forum_index();
            }
            // ...or use the existing page content?
        } else {
            $new_content = apply_filters('the_content', $page->post_content);
        }
        // Should we replace the title...
        if (empty($page->post_title)) {
            // Use the topics archive
            if ('topics' === bbp_show_on_root()) {
                $new_title = bbp_get_topic_archive_title();
                // No page so show the archive
            } else {
                $new_title = bbp_get_forum_archive_title();
            }
            // ...or use the existing page title?
        } else {
            $new_title = apply_filters('the_title', $page->post_title);
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => $new_title, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Forum
    } elseif (bbp_is_forum_edit()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_forum_form(), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
    } elseif (bbp_is_single_forum()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_forum(array('id' => bbp_get_forum_id())), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
        // Should we replace the content...
        if (empty($page->post_content)) {
            $new_content = $bbp_shortcodes->display_topic_index();
            // ...or use the existing page content?
        } else {
            $new_content = apply_filters('the_content', $page->post_content);
        }
        // Should we replace the title...
        if (empty($page->post_title)) {
            $new_title = bbp_get_topic_archive_title();
            // ...or use the existing page title?
        } else {
            $new_title = apply_filters('the_title', $page->post_title);
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Topic
    } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
        // Split
        if (bbp_is_topic_split()) {
            $new_content = bbp_buffer_template_part('form', 'topic-split', false);
            // Merge
        } elseif (bbp_is_topic_merge()) {
            $new_content = bbp_buffer_template_part('form', 'topic-merge', false);
            // Edit
        } elseif (bbp_is_topic_edit()) {
            $new_content = $bbp_shortcodes->display_topic_form();
            // Single
        } else {
            $new_content = $bbp_shortcodes->display_topic(array('id' => bbp_get_topic_id()));
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_reply_index(), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        // Single Reply
    } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
        // Move
        if (bbp_is_reply_move()) {
            $new_content = bbp_buffer_template_part('form', 'reply-move', false);
            // Edit
        } elseif (bbp_is_reply_edit()) {
            $new_content = $bbp_shortcodes->display_reply_form();
            // Single
        } else {
            $new_content = $bbp_shortcodes->display_reply(array('id' => get_the_ID()));
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed'));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_view(array('id' => get_query_var(bbp_get_view_rewrite_id()))), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Search ************************************************************/
    } elseif (bbp_is_search()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_search_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_search(array('search' => get_query_var(bbp_get_search_rewrite_id()))), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Topic Tags ********************************************************/
        // Topic Tag Edit
    } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
        // Stash the current term in a new var
        set_query_var('bbp_topic_tag', get_query_var('term'));
        // Show topics of tag
        if (bbp_is_topic_tag()) {
            $new_content = $bbp_shortcodes->display_topics_of_tag(array('id' => bbp_get_topic_tag_id()));
            // Edit topic tag
        } elseif (bbp_is_topic_tag_edit()) {
            $new_content = $bbp_shortcodes->display_topic_tag_form();
        }
        // Reset the post with our new title
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed', 'is_tax' => true));
    }
    /**
     * Bail if the template already matches a bbPress template. This includes
     * archive-* and single-* WordPress post_type matches (allowing
     * themes to use the expected format) as well as all bbPress-specific
     * template files for users, topics, forums, etc...
     *
     * We do this after the above checks to prevent incorrect 404 body classes
     * and header statuses, as well as to set the post global as needed.
     *
     * @see https://bbpress.trac.wordpress.org/ticket/1478/
     */
    if (bbp_is_template_included()) {
        return $template;
        /**
         * If we are relying on bbPress's built in theme compatibility to load
         * the proper content, we need to intercept the_content, replace the
         * output, and display ours instead.
         *
         * To do this, we first remove all filters from 'the_content' and hook
         * our own function into it, which runs a series of checks to determine
         * the context, and then uses the built in shortcodes to output the
         * correct results from inside an output buffer.
         *
         * Uses bbp_get_theme_compat_templates() to provide fall-backs that
         * should be coded without superfluous mark-up and logic (prev/next
         * navigation, comments, date/time, etc...)
         *
         * Hook into the 'bbp_get_bbpress_template' to override the array of
         * possible templates, or 'bbp_bbpress_template' to override the result.
         */
    } elseif (bbp_is_theme_compat_active()) {
        bbp_remove_all_filters('the_content');
        $template = bbp_get_theme_compat_templates();
    }
    return apply_filters('bbp_template_include_theme_compat', $template);
}
Exemple #20
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);
 }
Exemple #21
0
function fix_bbp_404()
{
    global $wp_query;
    if (class_exists('bbPress')) {
        if (bbp_is_single_user() || bbp_is_single_user_edit()) {
            if ($wp_query->bbp_is_single_user || $wp_query->bbp_is_single_user_edit || $wp_query->bbp_is_view) {
                $wp_query->is_404 = false;
                // Unset nocache_headers
                foreach (wp_get_nocache_headers() as $name => $field_value) {
                    @header("{$name}: ");
                }
                // Set status 200
                status_header(200);
            }
        }
    }
}
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $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, breadcrumbs_plus_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', 'theme_front');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'theme_front');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_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', 'theme_front');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_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');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
Exemple #23
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;
 }
Exemple #24
0
 static function media_view_settings($settings, $post)
 {
     $forum_id = 0;
     if (is_admin()) {
     } elseif (bbp_is_single_user_edit() || bbp_is_single_user()) {
     } elseif (bbp_is_forum_archive()) {
     } elseif (bbp_is_forum_edit()) {
         $forum_id = bbp_get_forum_id();
     } elseif (bbp_is_single_forum()) {
         $forum_id = bbp_get_forum_id();
     } elseif (bbp_is_topic_archive()) {
     } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
         $forum_id = bbp_get_forum_id();
     } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
     } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
         $forum_id = bbp_get_forum_id();
     } elseif (bbp_is_single_view()) {
     } elseif (bbp_is_search()) {
     } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
         $forum_id = bbp_get_forum_id();
     }
     if ($forum_id) {
         // @setcookie('_bbp_forum_id', $forum_id, 0, COOKIEPATH, COOKIE_DOMAIN);
         if (empty($settings['post'])) {
             $settings['post'] = array('id' => $forum_id, 'nonce' => wp_create_nonce('update-post_' . $forum_id));
         }
     } else {
         // @setcookie('_bbp_forum_id', ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
     }
     return $settings;
 }
Exemple #25
0
/**
 * Redirect if unathorized user is attempting to edit another user
 *
 * This is hooked to 'bbp_template_redirect' and controls the conditions under
 * which a user can edit another user (or themselves.) If these conditions are
 * met. We assume a user cannot perform this task, and look for ways they can
 * earn the ability to access this template.
 * 
 * @since bbPress (r3605)
 *
 * @uses bbp_is_topic_edit()
 * @uses current_user_can()
 * @uses bbp_get_topic_id()
 * @uses wp_safe_redirect()
 * @uses bbp_get_topic_permalink()
 */
function bbp_check_user_edit()
{
    // Bail if not editing a topic
    if (!bbp_is_single_user_edit()) {
        return;
    }
    // Default to false
    $redirect = true;
    // Allow user to edit their own profile
    if (bbp_is_user_home_edit()) {
        $redirect = false;
        // Allow if current user can edit the displayed user
    } elseif (current_user_can('edit_user', bbp_get_displayed_user_id())) {
        $redirect = false;
        // Allow if user can manage network users, or edit-any is enabled
    } elseif (current_user_can('manage_network_users') || apply_filters('enable_edit_any_user_configuration', false)) {
        $redirect = false;
    }
    // Maybe redirect back to profile page
    if (true === $redirect) {
        wp_safe_redirect(bbp_get_user_profile_url(bbp_get_displayed_user_id()));
        exit;
    }
}
/**
 * Output forum role selector (for user edit)
 *
 * @since 2.2.0 bbPress (r4284)
 */
function bbp_edit_user_forums_role()
{
    // Return if no user is being edited
    if (!bbp_is_single_user_edit()) {
        return;
    }
    // Get the user's current forum role
    $user_role = bbp_get_user_role(bbp_get_displayed_user_id());
    // Get the folum roles
    $dynamic_roles = bbp_get_dynamic_roles();
    // Only keymasters can set other keymasters
    if (!bbp_is_user_keymaster()) {
        unset($dynamic_roles[bbp_get_keymaster_role()]);
    }
    ?>

	<select name="bbp-forums-role" id="bbp-forums-role">
		<option value=""><?php 
    esc_html_e('&mdash; No role for these forums &mdash;', 'bbpress');
    ?>
</option>

		<?php 
    foreach ($dynamic_roles as $role => $details) {
        ?>

			<option <?php 
        selected($user_role, $role);
        ?>
 value="<?php 
        echo esc_attr($role);
        ?>
"><?php 
        echo bbp_translate_user_role($details['name']);
        ?>
</option>

		<?php 
    }
    ?>

	</select>

	<?php 
}
Exemple #27
0
/**
 * Gets the items for the breadcrumb trail if bbPress is installed.
 *
 * @since 0.5.0
 * @access public
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the trail.
 */
function breadcrumb_trail_get_bbpress_items($args = array())
{
    /* Set up a new trail items array. */
    $trail = array();
    /* 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()) {
        $trail[] = '<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()) {
        $trail[] = "<span>" . bbp_get_forum_archive_title() . "</span>";
    } elseif (bbp_is_topic_archive()) {
        $trail[] = "<span>" . bbp_get_topic_archive_title() . "</span>";
    } elseif (bbp_is_topic_tag()) {
        $trail[] = "<span>" . bbp_get_topic_tag_name() . "</span>";
    } elseif (bbp_is_topic_tag_edit()) {
        $trail[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
        $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
    } elseif (bbp_is_single_view()) {
        $trail[] = '<span>' . bbp_get_view_title() . '</span>';
    } 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). */
        $trail = array_merge($trail, breadcrumb_trail_get_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()) {
            $trail[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $trail[] = '<span>' . bbp_get_topic_title($topic_id) . '</span>';
        }
        /* If viewing a topic split page. */
        if (bbp_is_topic_split()) {
            $trail[] = "<span>" . __('Split', 'kleo_framework') . "</span>";
        } elseif (bbp_is_topic_merge()) {
            $trail[] = "<span>" . __('Merge', 'kleo_framework') . "</span>";
        } elseif (bbp_is_topic_edit()) {
            $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
        }
    } 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. */
        $trail = array_merge($trail, breadcrumb_trail_get_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()) {
            $trail[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
        } else {
            $trail[] = '<span>' . bbp_get_reply_title($reply_id) . '</span>';
        }
    } 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) {
            $trail = array_merge($trail, breadcrumb_trail_get_parents($forum_parent_id));
        }
        /* Add the forum title to the end of the trail. */
        $trail[] = '<span>' . bbp_get_forum_title($forum_id) . '</span>';
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $trail[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
        } else {
            $trail[] = '<span>' . bbp_get_displayed_user_field('display_name') . '</span>';
        }
    }
    /* Return the bbPress breadcrumb trail items. */
    return apply_filters('breadcrumb_trail_get_bbpress_items', $trail, $args);
}
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $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()) {
        if (function_exists('bp_is_active')) {
            global $bp;
            // we're outside the loop!
            // Assign some variables here
            $page1 = isset($bp->members->root_slug) ? $bp->members->root_slug : '';
            // slug for the Members page. The BuddyPress default is 'members'.
            $page2 = isset($bp->groups->root_slug) ? $bp->groups->root_slug : '';
            // slug for the Groups page. The BuddyPress default is 'groups'.
            $page3 = isset($bp->activity->root_slug) ? $bp->activity->root_slug : '';
            // slug for the Activity page. The BuddyPress default is 'activity'.
            $page4 = isset($bp->forums->root_slug) ? $bp->forums->root_slug : '';
            // slug for the Forums page. The BuddyPress default is 'forums'.
            $page5 = isset($bp->achievements->root_slug) ? $bp->achievements->root_slug : '';
            // slug for the Achievements page. The BuddyPress default is 'achievements'.
            if (!bp_is_blog_page() && (is_page() || is_page($page1) || is_page($page2) || is_page($page3) || is_page($page4) || is_page($page5)) && !bp_is_user() && !bp_is_single_item() && !bp_is_register_page()) {
                $item[] = '';
            }
            if (bp_is_user() && !bp_is_register_page()) {
                $item[] = '';
            }
        } else {
            //$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
        }
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } else {
        $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
    }
    if (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, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '" rel="v:url" property="v:title">' . bbp_get_topic_title($topic_id) . '</a></div>';
        } else {
            $item[] = '';
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'framework');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'framework');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'framework');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '" rel="v:url" property="v:title">' . bbp_get_reply_title($reply_id) . '</a></div>';
            $item[] = __('Edit', '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, breadcrumbs_plus_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[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '" rel="v:url" property="v:title">' . bbp_get_displayed_user_field('display_name') . '</a></div>';
            $item[] = __('Edit', 'framework');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
 /**
  * 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);
 }
/**
 * Redirect if unathorized user is attempting to edit another user
 *
 * This is hooked to 'bbp_template_redirect' and controls the conditions under
 * which a user can edit another user (or themselves.) If these conditions are
 * met, we assume a user cannot perform this task, and look for ways they can
 * earn the ability to access this template.
 *
 * @since 2.1.0 bbPress (r3605)
 *
 * @uses bbp_is_single_user_edit()
 * @uses current_user_can()
 * @uses bbp_get_displayed_user_id()
 * @uses bbp_redirect()
 * @uses bbp_get_user_profile_url()
 */
function bbp_check_user_edit()
{
    // Bail if not editing a user
    if (!bbp_is_single_user_edit()) {
        return;
    }
    // Default to false
    $redirect = true;
    $user_id = bbp_get_displayed_user_id();
    // Allow user to edit their own profile
    if (bbp_is_user_home_edit()) {
        $redirect = false;
        // Allow if current user can edit the displayed user
    } elseif (current_user_can('edit_user', $user_id)) {
        $redirect = false;
        // Allow if user can manage network users, or edit-any is enabled
    } elseif (current_user_can('manage_network_users') || apply_filters('enable_edit_any_user_configuration', false)) {
        $redirect = false;
    }
    // Allow conclusion to be overridden
    $redirect = (bool) apply_filters('bbp_check_user_edit', $redirect, $user_id);
    // Bail if not redirecting
    if (false === $redirect) {
        return;
    }
    // Filter redirect URL
    $profile_url = bbp_get_user_profile_url($user_id);
    $redirect_to = apply_filters('bbp_check_user_edit_redirect_to', $profile_url, $user_id);
    // Redirect
    bbp_redirect($redirect_to);
}