Nik_S (@nik_s)

Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • @nik_s

    Participant

    Solved! Going line by line through the Bones theme I discovered that the call to load jQuery <script type="text/javascript" src="/wp-content/themes/bones/library/js/jquery.js"></script> was located in the theme’s footer “for faster loading.” Moving this line to the header fixed the problem. Still not quite sure why – seems the editor cannot wait for jQuery to load – but at this point I’m just glad it’s sorted. Thanks again for your help @robin-w.

    @nik_s

    Participant

    @robin-w it is a version of Bones (modified for the website template):

    Bones

    But I don’t recall adding any special functions or anything that could be causing this.

    @nik_s

    Participant

    Hi Robin, no change when I disabled all other plugins but switching the theme to the 2015 WordPress default corrected the problem.

    So, something in my theme is hiding it, and only hiding it when someone is logged in. Any ideas what could be doing this or where I should look? I can’t find anything that looks significant in the theme’s functions.php file but I suppose I don’t know what I’m searching for.

    Thanks for your help!

    @nik_s

    Participant

    Yes, that is the plan, although we might turn it off if spam becomes a problem. But toggling the Anonymous Posting setting does not seem to fix the issue.

    @nik_s

    Participant

    Hi,

    Here is what the editor looks like when logged out:
    http://www.sva.bc.ca/logged_out.png

    And here is what it looks like when logged in, with any user role:
    http://www.sva.bc.ca/logged_in.png

    Note the TinyMCE/Quicktags editor buttons are missing. The images above show this for the topic creation but it’s the same for replies. Here is the HTML code that appears when I inspect the element (while logged in):

    <div id="wp-bbp_topic_content-editor-container" class="wp-editor-container">
        <div id="qt_bbp_topic_content_toolbar" class="quicktags-toolbar"></div>
        <textarea id="bbp_topic_content" class="bbp-the-content wp-editor-area" name="bbp_topic_content" cols="40" tabindex="102" rows="12">
        </textarea>
    </div>

    @nik_s

    Participant

    Hi,

    The permalinks are set to “Post name”.

    @nik_s

    Participant

    Yes, I tried all the repair tools sequentially.

    To clarify, by manual import I mean I added each topic and reply by hand from the WordPress dashboard and a plugin to change the post authors.

    Main issue now is I that I don’t know how to change the permalinks to match the ones corresponding to the “Published Date” I retroactively selected for each post, rather than the date I created those posts.

    @nik_s

    Participant

    Managed to solve the problem using this code:

    <?php
    
    //this function changes the bbp freshness data (time since) into a last post date for forums
    function change_freshness_forum ($forum_id = 0 ) {
    
    // Verify forum and get last active meta
    		$forum_id = bbp_get_forum_id( $forum_id );
    
    			// Get the date for the most recent reply and topic in each forum
    			$reply_id = bbp_get_forum_last_reply_id( $forum_id );
    			if ( !empty( $reply_id ) ) {
    				$last_active_reply_date = get_the_date( '', $reply_id );
    			}
    			$topic_id = bbp_get_forum_last_topic_id( $forum_id );
    			if ( !empty( $topic_id ) ) {
    				$last_active_topic_date = get_the_date('', $topic_id );
    			}
    
    			// Compare the reply and topic dates, and assign the most recent one to $last_active_date
    				if ( !empty($last_active_reply_date ) && !empty($last_active_topic_date) ) {
    					$last_active_date = ((strtotime($last_active_topic_date) >= strtotime($last_active_reply_date)) ? $last_active_topic_date : $last_active_reply_date );
    				} elseif (empty($last_active_reply_date)) {
    					$last_active_date = $last_active_topic_date ;
    				} else {
    					$last_active_date = $last_active_reply_date ;
    				}
    
    			// Get the time for the most recent reply and topic in each forum
    			if ( !empty( $reply_id ) ) {
    				$last_active_reply_time = get_the_time( '', $reply_id );
    			}
    			if ( !empty( $topic_id ) ) {
    				$last_active_topic_time = get_the_time('', $topic_id );
    			}
    
    			// Compare the reply and topic times, and assign the most recent one to $last_active_time
    				if ( !empty($last_active_reply_time ) && !empty($last_active_topic_time) ) {
    					$last_active_time = ((strtotime($last_active_topic_time) >= strtotime($last_active_reply_time)) ? $last_active_topic_time : $last_active_reply_time );
    				} elseif (empty($last_active_reply_time)) {
    					$last_active_time = $last_active_topic_time ;
    				} else {
    					$last_active_time = $last_active_reply_time ;
    				}
    			
    		$last_active_date = bbp_convert_date( $last_active_date ) ;
    		$last_active_time = bbp_convert_date( $last_active_time ) ;
    		$date_format = get_option( 'date_format' );
    		$time_format = get_option( 'time_format' );
    		$date= date_i18n( "{$date_format}", $last_active_date );
    		$time=date_i18n( "{$time_format}", $last_active_time );
    		$active_time = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbp-last-post' ), $date, $time );  
    		return $active_time ;
    		}
    add_filter( 'bbp_get_forum_last_active', 'change_freshness_forum', 10, 2 );
    
    //this function changes the bbp freshness data (time since) into a last post date for topics
    function change_freshness_topic ($last_active, $topic_id) {
    
    $topic_id = bbp_get_topic_id( $topic_id );
    
    		// Try to get the most accurate freshness date possible
    		if ( empty( $last_active_date ) ) {
    		$reply_id = bbp_get_topic_last_reply_id( $topic_id );
    		if ( !empty( $reply_id ) ) {
    			$last_active_date = get_the_date( '', $reply_id );
    		} else {
    				$last_active_date = get_the_date( '', $topic_id );
    			}
    		}
    
    		// Try to get the most accurate freshness time possible
    		if ( empty( $last_active_time ) ) {
    		$reply_id = bbp_get_topic_last_reply_id( $topic_id );
    		if ( !empty( $reply_id ) ) {
    			$last_active_time = get_the_time( '', $reply_id );
    		} else {
    				$last_active_time = get_the_time( '', $topic_id );
    			}
    		}
    		
    		
    		$last_active_date = bbp_convert_date( $last_active_date ) ;
    		$last_active_time = bbp_convert_date( $last_active_time ) ;
    		$date_format = get_option( 'date_format' );
    		$time_format = get_option( 'time_format' );
    		$date= date_i18n( "{$date_format}", $last_active_date );
    		$time=date_i18n( "{$time_format}", $last_active_time );
    		$active_time = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbp-last-post' ), $date, $time );
    		return $active_time ;
    		}
    add_filter( 'bbp_get_topic_last_active', 'change_freshness_topic', 10, 2 );
    
    //This function changes the heading "Freshness" to the name created in Settings>bbp last post
    function change_translate_text( $translated_text ) {
    	$text = 'Freshness' ;
    	if ( $translated_text == $text ) {
    	global $rlp_options;
    	$translated_text = $rlp_options['heading_label'];
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'change_translate_text', 20 );

    But now another issue has become apparent – the permalinks and anchor tag titles still refer to either bbp_get_forum_last_topic_permalink or bbp_get_forum_last_reply_url (I think) and not to the most recent post or topic as I have defined it above. Any ideas on how I can change the last_topic or last_reply permalinks to match the ones corresponding to the displayed dates? This is just a touch beyond my current PHP skills and so would greatly appreciate any suggestions.

Viewing 8 replies - 1 through 8 (of 8 total)