Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 3,476 through 3,500 (of 32,517 total)
  • Author
    Search Results
  • #205183
    Robin W
    Moderator

    the simplest way would be to put this in your theme’s custom css area

    img.avatar {
    	display : none ;
    }
    #205169
    Danishsard
    Participant

    Hello, on the list of forum topics avatery are visible, how can I hide or delete them. I just need a username without these pictures.

    I don’t know where to turn it on or how to enable it, even by editing the forum file code

    My forum page https://infomiasto.eu/forum/tematy/rozmowy/

    #205167

    In reply to: Working Member List?

    Robin W
    Moderator

    this is code from bbpress version 1 – 9 years ago, unlikely to work

    berry metal
    Participant

    I don’t use hand-coded, inline tempolates. I am using Templatera of WPBakery, and I am happy with it as it gives me a graphical overview of the structure, and they are easy to re-make or replace.

    In WPBakery, I have a javascript module, an html module, but there is no PHP module.

    But there is a text module which does accept shortcodes.
    What do you recommend in this scenario?

    Robin W
    Moderator

    the code would go in your single post template – not having seen the template, I can’t say where !

    I was presuming that you were editing this template and Ftp’ing it to your site, in which case, yes it could break it, but you’d just keep a copy of the old template and FTP that back. If you have debugging switched on, then this will tell you where the error is to let you correct

    #205152

    In reply to: bbpress Loop Argument

    Babblebey
    Participant

    Thank you once again, Robin

    <?php
    if ( babblebey_has_topics() ):
        while ( bbp_topics() ) : bbp_the_topic();
            get_template_part( 'template-parts/topic', 'card' );
        endwhile;
    endif;
    ?>

    I used it like that

    #205151

    In reply to: bbpress Loop Argument

    Babblebey
    Participant

    So I will be calling babblebey_has_topics() ?????? Please see as stated below too

    
    <!--Sidebar Start-->
                <div class="col-md-4">
                          <div class="sidebar-topics row sticky-top">
                              <div class="col-md-12 col-sm-12 col-12 ml-2 mb-2 p-1">
                                    <h3 class="">Latest Forum Topic</h3>
                              </div>
                              <div class="col-md-12 col-sm-12 col-12">
                            <?php
                                if ( babblebey_has_topics() ):
                                    while ( babblebey_topics() ) : babblebey_the_topic();
                                        get_template_part( 'template-parts/topic', 'card' );
                                    endwhile;
                                endif;
                              ?>
                            </div>
                      </div>
                </div>
    <!--Sidebar Ends-->
    
    #205150

    In reply to: bbpress Loop Argument

    Robin W
    Moderator

    I’d be tempted to just clone the bbp_has_topics function

    eg

    add this to your functions file

    function babblebey_has_topics( $args = '' ) {
    	global $wp_rewrite;
    
    	/** Defaults **************************************************************/
    
    	// Other defaults
    	$default_topic_search  = !empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;
    	$default_show_stickies = (bool) ( bbp_is_single_forum() || bbp_is_topic_archive() ) && ( false === $default_topic_search );
    	$default_post_parent   = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    
    	// Default argument array
    	$default = array(
    		'post_type'      => bbp_get_topic_post_type(), // Narrow query down to bbPress topics
    		'post_parent'    => $default_post_parent,      // Forum ID
    		'meta_key'       => '_bbp_last_active_time',   // Make sure topic has some last activity time
    		'orderby'        => 'meta_value',              // 'meta_value', 'author', 'date', 'title', 'modified', 'parent', rand',
    		'order'          => 'DESC',                    // 'ASC', 'DESC'
    		'posts_per_page' => -1, 						// Topics per page
    		'paged'          => bbp_get_paged(),           // Page Number
    		's'              => $default_topic_search,     // Topic Search
    		'show_stickies'  => $default_show_stickies,    // Ignore sticky topics?
    		'max_num_pages'  => false,                     // Maximum number of pages to show
    	);
    
    	// What are the default allowed statuses (based on user caps)
    	if ( bbp_get_view_all() ) {
    
    		// Default view=all statuses
    		$post_statuses = array(
    			bbp_get_public_status_id(),
    			bbp_get_closed_status_id(),
    			bbp_get_spam_status_id(),
    			bbp_get_trash_status_id()
    		);
    
    		// Add support for private status
    		if ( current_user_can( 'read_private_topics' ) ) {
    			$post_statuses[] = bbp_get_private_status_id();
    		}
    
    		// Join post statuses together
    		$default['post_status'] = implode( ',', $post_statuses );
    
    	// Lean on the 'perm' query var value of 'readable' to provide statuses
    	} else {
    		$default['perm'] = 'readable';
    	}
    
    	// Maybe query for topic tags
    	if ( bbp_is_topic_tag() ) {
    		$default['term']     = bbp_get_topic_tag_slug();
    		$default['taxonomy'] = bbp_get_topic_tag_tax_id();
    	}
    
    	/** Setup *****************************************************************/
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, $default, 'babblebey_topics' );
    
    	// Get bbPress
    	$bbp = bbpress();
    
    	// Call the query
    	$bbp->topic_query = new WP_Query( $r );
    
    	// Set post_parent back to 0 if originally set to 'any'
    	if ( 'any' === $r['post_parent'] )
    		$r['post_parent'] = 0;
    
    	// Limited the number of pages shown
    	if ( !empty( $r['max_num_pages'] ) )
    		$bbp->topic_query->max_num_pages = $r['max_num_pages'];
    
    	/** Stickies **************************************************************/
    
    	// Put sticky posts at the top of the posts array
    	if ( !empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) {
    
    		// Get super stickies and stickies in this forum
    		$stickies = bbp_get_super_stickies();
    
    		// Get stickies for current forum
    		if ( !empty( $r['post_parent'] ) ) {
    			$stickies = array_merge( $stickies, bbp_get_stickies( $r['post_parent'] ) );
    		}
    
    		// Remove any duplicate stickies
    		$stickies = array_unique( $stickies );
    
    		// We have stickies
    		if ( is_array( $stickies ) && !empty( $stickies ) ) {
    
    			// Start the offset at -1 so first sticky is at correct 0 offset
    			$sticky_offset = -1;
    
    			// Loop over topics and relocate stickies to the front.
    			foreach ( $stickies as $sticky_index => $sticky_ID ) {
    
    				// Get the post offset from the posts array
    				$post_offsets = wp_filter_object_list( $bbp->topic_query->posts, array( 'ID' => $sticky_ID ), 'OR', 'ID' );
    
    				// Continue if no post offsets
    				if ( empty( $post_offsets ) ) {
    					continue;
    				}
    
    				// Loop over posts in current query and splice them into position
    				foreach ( array_keys( $post_offsets ) as $post_offset ) {
    					$sticky_offset++;
    
    					$sticky = $bbp->topic_query->posts[$post_offset];
    
    					// Remove sticky from current position
    					array_splice( $bbp->topic_query->posts, $post_offset, 1 );
    
    					// Move to front, after other stickies
    					array_splice( $bbp->topic_query->posts, $sticky_offset, 0, array( $sticky ) );
    
    					// Cleanup
    					unset( $stickies[$sticky_index] );
    					unset( $sticky );
    				}
    
    				// Cleanup
    				unset( $post_offsets );
    			}
    
    			// Cleanup
    			unset( $sticky_offset );
    
    			// If any posts have been excluded specifically, Ignore those that are sticky.
    			if ( !empty( $stickies ) && !empty( $r['post__not_in'] ) ) {
    				$stickies = array_diff( $stickies, $r['post__not_in'] );
    			}
    
    			// Fetch sticky posts that weren't in the query results
    			if ( !empty( $stickies ) ) {
    
    				// Query to use in get_posts to get sticky posts
    				$sticky_query = array(
    					'post_type'   => bbp_get_topic_post_type(),
    					'post_parent' => 'any',
    					'meta_key'    => '_bbp_last_active_time',
    					'orderby'     => 'meta_value',
    					'order'       => 'DESC',
    					'include'     => $stickies
    				);
    
    				// Cleanup
    				unset( $stickies );
    
    				// Conditionally exclude private/hidden forum ID's
    				$exclude_forum_ids = bbp_exclude_forum_ids( 'array' );
    				if ( ! empty( $exclude_forum_ids ) ) {
    					$sticky_query['post_parent__not_in'] = $exclude_forum_ids;
    				}
    
    				// What are the default allowed statuses (based on user caps)
    				if ( bbp_get_view_all() ) {
    					$sticky_query['post_status'] = $r['post_status'];
    
    				// Lean on the 'perm' query var value of 'readable' to provide statuses
    				} else {
    					$sticky_query['post_status'] = $r['perm'];
    				}
    
    				// Get all stickies
    				$sticky_posts = get_posts( $sticky_query );
    				if ( !empty( $sticky_posts ) ) {
    
    					// Get a count of the visible stickies
    					$sticky_count = count( $sticky_posts );
    
    					// Merge the stickies topics with the query topics .
    					$bbp->topic_query->posts       = array_merge( $sticky_posts, $bbp->topic_query->posts );
    
    					// Adjust loop and counts for new sticky positions
    					$bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
    					$bbp->topic_query->post_count  = (int) $bbp->topic_query->post_count  + (int) $sticky_count;
    
    					// Cleanup
    					unset( $sticky_posts );
    				}
    			}
    		}
    	}
    
    	// If no limit to posts per page, set it to the current post_count
    	if ( -1 === $r['posts_per_page'] )
    		$r['posts_per_page'] = $bbp->topic_query->post_count;
    
    	// Add pagination values to query object
    	$bbp->topic_query->posts_per_page = $r['posts_per_page'];
    	$bbp->topic_query->paged          = $r['paged'];
    
    	// Only add pagination if query returned results
    	if ( ( (int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts ) && (int) $bbp->topic_query->posts_per_page ) {
    
    		// Limit the number of topics shown based on maximum allowed pages
    		if ( ( !empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count )
    			$bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
    
    		// If pretty permalinks are enabled, make our pagination pretty
    		if ( $wp_rewrite->using_permalinks() ) {
    
    			// User's topics
    			if ( bbp_is_single_user_topics() ) {
    				$base = bbp_get_user_topics_created_url( bbp_get_displayed_user_id() );
    
    			// User's favorites
    			} elseif ( bbp_is_favorites() ) {
    				$base = bbp_get_favorites_permalink( bbp_get_displayed_user_id() );
    
    			// User's subscriptions
    			} elseif ( bbp_is_subscriptions() ) {
    				$base = bbp_get_subscriptions_permalink( bbp_get_displayed_user_id() );
    
    			// Root profile page
    			} elseif ( bbp_is_single_user() ) {
    				$base = bbp_get_user_profile_url( bbp_get_displayed_user_id() );
    
    			// View
    			} elseif ( bbp_is_single_view() ) {
    				$base = bbp_get_view_url();
    
    			// Topic tag
    			} elseif ( bbp_is_topic_tag() ) {
    				$base = bbp_get_topic_tag_link();
    
    			// Page or single post
    			} elseif ( is_page() || is_single() ) {
    				$base = get_permalink();
    
    			// Forum archive
    			} elseif ( bbp_is_forum_archive() ) {
    				$base = bbp_get_forums_url();
    
    			// Topic archive
    			} elseif ( bbp_is_topic_archive() ) {
    				$base = bbp_get_topics_url();
    
    			// Default
    			} else {
    				$base = get_permalink( (int) $r['post_parent'] );
    			}
    
    			// Use pagination base
    			$base = trailingslashit( $base ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
    
    		// Unpretty pagination
    		} else {
    			$base = add_query_arg( 'paged', '%#%' );
    		}
    
    		// Pagination settings with filter
    		$bbp_topic_pagination = apply_filters( 'bbp_topic_pagination', array (
    			'base'      => $base,
    			'format'    => '',
    			'total'     => $r['posts_per_page'] === $bbp->topic_query->found_posts ? 1 : ceil( (int) $bbp->topic_query->found_posts / (int) $r['posts_per_page'] ),
    			'current'   => (int) $bbp->topic_query->paged,
    			'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
    			'next_text' => is_rtl() ? '&larr;' : '&rarr;',
    			'mid_size'  => 1
    		) );
    
    		// Add pagination to query object
    		$bbp->topic_query->pagination_links = paginate_links( $bbp_topic_pagination );
    
    		// Remove first page from pagination
    		$bbp->topic_query->pagination_links = str_replace( $wp_rewrite->pagination_base . "/1/'", "'", $bbp->topic_query->pagination_links );
    	}
    
    	// Return object
    	return apply_filters( 'babblebey_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query );
    }

    which is just bbp_has_topics’ renamed with pagination changed to -1

    and then call that

    berry metal
    Participant

    Thank you!
    Should I insert the code above in my functions.php as it is, and use [bbp-single-topic id='.$forum_id.'] in my template?
    The fact that is not tested, can it break my site?

    Robin W
    Moderator

    untested, but try

    $title = get_the_title() ;
    $forums = bbp_get_forums_for_current_user() ;
    	foreach ($forums as $forum) {
    		if ($forum->post_title == $title) {
    			$forum_id= $forum->ID ;
    		}
    	}
    do_shortcode( '[bbp-single-topic id='.$forum_id.']' );	
    #205143

    In reply to: bbpress Loop Argument

    Babblebey
    Participant

    The Post Per Page as its been set up from the “Forum Setting”:

    screenshot-localhost-2019-11-01-17-53-12

    Works as it should, i.e dictate the number of topics to display per Single Forum Page:

    screenshot-localhost-2019-11-01-17-50-24

    But the same setting is inturn affecting my custom loop I have placed on my HomePage Sticky Sidebar to display latest topics:

    screenshot-localhost-2019-11-01-17-56-53

    I want something similar to the ` $args = array(‘posts_per_page’ => 10 //my custom number) as its being used in the normal WP Post Loop like this below:


    <?php $args = array(
    ‘posts_per_page’ => 10 // Like this one here
    );
    $posts = new WP_Query($args);
    if ($posts->have_posts()):
    while($posts->have_posts()): $posts->the_post();
    get_template_part( ‘template-parts/content’, get_post_format() );
    endwhile;
    endif;
    wp_reset_postdata(); ?>
    `

    Robin W
    Moderator

    so where are you placing this code ? eg in a page template?

    #205140
    Robin W
    Moderator

    bbp_is_user_subscribed_to_topic()

    bbp_is_user_favorite( $user_id, $topic_id );

    berry metal
    Participant

    I want to output bbPress single topic shortcodes with different IDs, through my single post template.

    On post with the title “A” shortcode [bbp-single-topic id=6041], on post with the title “B” shortcode [bbp-single-topic id=6042], etc…

    And the matching I need it via title strings, meaning that the topic with id 6041 would have the title “A”, and the topic with id 6042 would have the title “B”.

    How to achieve this, and what would be the dynamic query?

    I am using bbPress instead of comments, as they are post type, and I want to use this advantage.

    #205138

    In reply to: bbpress Loop Argument

    Robin W
    Moderator

    given that

    get_template_part( ‘template-parts/topic’, ‘card’ );

    is from your theme (or other plugin) not bbpress, not sure what is taking the pagination.

    the usual solution would be to parse args eg

    add_filter ('bbp_before_has_topics_parse_args', rew_has_topics') ;
    
    function rew_has_topics( $args = '' ) {
    	$args['posts_per_page'] = '-1' ;
    return $args;
    }
    #205137
    Babblebey
    Participant

    Thank you very much.

    If only the codex https://codex.bbpress.org/developer/ was completed.

    Please, I might need the same for if A TOPIC is Favourited and if a TOPIC is Subscribed to

    #205136
    Robin W
    Moderator

    bbp_is_user_subscribed_to_forum($forum)

    Babblebey
    Participant

    Hello there,

    Thank you for viewing this thread.

    I am trying to set a button for based on users current forum subscription status

    When a User “is not Subcribed” to Current Forum

     
    <button type="button" class="btn-lg omna-btn-green shadow-sm" id="forum-subscription-btn"><i class="fa fa-bell"></i> <?php bbp_forum_subscription_link(); ?></button>
    <p>Subscribe to this forum and get updates on latest topics</p>
    

    screenshot-localhost-2019-11-01-17-05-28

    When a User “is Subscribed” to Current Forum

     
    <button type="button" class="btn-lg omna-btn-green shadow-sm" id="forum-subscription-btn"><i class="fa fa-bell-slash"></i> <?php bbp_forum_subscription_link(); ?></button>
    <p>Unsubscribe from this forum and stop receiving updates on latest topics</p>
    

    screenshot-localhost-2019-11-01-17-09-06

    So My Code is suppose to look something like

    
    <?php if (user_is_subcribed_to_this_forum): ?>
        <button type="button" class="btn-lg omna-btn-green shadow-sm" id="forum-subscription-btn"><i class="fa fa-bell-slash"></i> <?php bbp_forum_subscription_link(); ?></button>
        <p>Unsubscribe from this forum and stop receiving updates on latest topics</p>
    <?php else: ?>
        <button type="button" class="btn-lg omna-btn-green shadow-sm" id="forum-subscription-btn"><i class="fa fa-bell"></i> <?php bbp_forum_subscription_link(); ?></button>
        <p>Subscribe to this forum and get updates on latest topics</p>
    <?php endif; ?>
    

    The right function to use in-place of user_is_subcribed_to_this_forum is what i seek.

    Thanking you in anticipation of a working response.

    #205134
    Babblebey
    Participant

    Hello there,

    Thank you for viewing this thread.

    I have a sidebar on the Homepage of my website that should list latest forum topics. But the number of topics listed is being determined by the “number of topics” set per-page in the “Forum Settings”.

    Is there a way to setup an argument($args) similarly to that of the new WP_Query($args) to set a custom of topics per-page.?

    Here’s my query:

    
    <!--Sidebar Start-->
                <div class="col-md-4">
                          <div class="sidebar-topics row sticky-top">
                              <div class="col-md-12 col-sm-12 col-12 ml-2 mb-2 p-1">
                                    <h3 class="">Latest Forum Topic</h3>
                              </div>
                              <div class="col-md-12 col-sm-12 col-12">
                            <?php
                                if ( bbp_has_topics() ):
                                    while ( bbp_topics() ) : bbp_the_topic();
                                        get_template_part( 'template-parts/topic', 'card' );
                                    endwhile;
                                endif;
                              ?>
                            </div>
                      </div>
                </div>
    <!--Sidebar Ends-->
    
    #205125
    Chuckie
    Participant

    Understood.

    This is the code in the functions php that needs updating:

    function bsp_load_spinner_topic () {
    	global $bsp_style_settings_form ;
    	//preload spinner so it is ready - css hides this
    	echo '<div id="bsp-spinner-load"></div>' ;
    	//add button - hidden by css
    	echo '<button type="submit" id="bsp_topic_submit" name="bbp_topic_submit" class="button submit">' ;
    	//leave as is if field is blanked (user may just want spinner)
    	$value = (!empty($bsp_style_settings_form['SubmittingSubmitting']) ? $bsp_style_settings_form['SubmittingSubmitting']  : '') ;
    	echo $value ;
    	//then add spinner if activated
    	if (!empty( $bsp_style_settings_form['SubmittingSpinner'])) echo '<span class="bsp-spinner"></span>' ;
    	//then finish button
    	echo '</button>' ;
    }
    	
    	
    function bsp_load_spinner_reply () {
    	global $bsp_style_settings_form ;
    	//preload spinner so it is ready - css hides this
    	echo '<div id="bsp-spinner-load"></div>' ;
    	//add button - hidden by css
    	echo '<button type="submit" id="bsp_reply_submit" name="bbp_reply_submit" class="button submit">' ;
    	//leave as is if field is blanked (user may just want spinner)
    	$value = (!empty($bsp_style_settings_form['SubmittingSubmitting']) ? $bsp_style_settings_form['SubmittingSubmitting']  : '') ;
    	echo $value ;
    	//then add spinner if activated
    	if (!empty ( $bsp_style_settings_form['SubmittingSpinner'])) echo '<span class="bsp-spinner"></span>' ;
    	//then finish button
    	echo '</button>' ;
    }

    Specifically:

    	//leave as is if field is blanked (user may just want spinner)
    	$value = (!empty($bsp_style_settings_form['SubmittingSubmitting']) ? $bsp_style_settings_form['SubmittingSubmitting']  : '') ;
    	echo $value ;
    

    So it looks to see if the user has entered a value in the settings for “Submitting” and if it is not empty echos it, else it echos nothing. Do functions like bbp_allow_revisions() work in this context?

    #205103
    Robin W
    Moderator

    then you need to amend form-topic and form-reply

    to amend

    <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_topic_submit" name="bbp_topic_submit" class="button submit"><?php _e( 'Submit', 'bbpress' ); ?></button>

    to something like (untested)

    <?php if ( bbp_allow_revisions() && bbp_is_topic_edit() ) : ?>
    <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_topic_submit" name="bbp_topic_submit" class="button submit"><?php _e( 'Submit', 'bbpress' ); ?></button>
    <?php endif ; ?>
    <?php else : ?>
    <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_topic_submit" name="bbp_topic_submit" class="button submit"><?php _e( 'Update', 'bbpress' ); ?></button>
    <?php endelse : ?>
    
    #205102
    Chuckie
    Participant

    Thank you. I think the problem I am going to have though is that for new topics, the right words are still Submit / Submitting. It is only editing topics that need the words replaced.

    Wouldn’t the above code replace in code contexts, based on your comment preceding the code?

    #205101
    Robin W
    Moderator
    //This function changes the text wherever it is quoted
    function change_translate_text( $translated_text ) {
    	if ( $translated_text == 'old text' ) {
    	$translated_text = 'new text';
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'change_translate_text', 20 );
    #205099
    Chuckie
    Participant

    After using the code tweak ($args['teeny'] = false;) I was then able to use this snippet:

    add_filter("mce_buttons", "tinymce_editor_buttons", 99); //targets the first line
    ​
    function tinymce_editor_buttons($buttons) {
    return array(
      "formatselect", 
      "bold",
      "italic",
      "underline",
      "bullist",
      "numlist",
      "blockquote",
      "justifyleft",
      "justifycenter",
      "justifyright",
      "code",
      "link",
      "unlink",
      "image",
      "wp_adv"
      //add more here...
      );
    }
    drjohndimi
    Participant

    Hello All.
    I think this would be a great feature to have. Once a user creates/submits a topic, a popup appears and prompts the user to share his/her post on FB, Twitter or Whatsapp (possibly with the button in the notification message.

    Is there already a solution to this out there (maybe in a plugin or helpful code).

    Thank you for your time.

    JD

Viewing 25 results - 3,476 through 3,500 (of 32,517 total)
Skip to toolbar