• Resolved tapiohuuhaa

    (@tapiohuuhaa)


    Hi
    Thank’s for the plugin but I don’t need it anymore just at all. Thank’s for all help. I learned from this plugin some own code. All needed style I can define with CSS.

    Currently the only issue, which I would need this plugin is setting freshness format.
    But I would like to use for that Code Snippet.

    Can I just get some information, how I could set it with PHP script or some advice, which core file of bbPress I should alter.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Robin W

    (@robin-w)

    style pack includes>functions.php and start at line 893

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Ok. I found functions, which I must modify:

    I get desired result (I look from source code of style pack settings, what to put as fixed values).

    https://www.sanaristikkofoorumi.net/wordpress/forums/forum/muut-aiheet/

    Thank’s. Below the working code:

    
    //this function changes the bbp freshness data (time since) into a last post date for forums
    function bsp_change_freshness_forum ($forum_id = 0 ) {
    	global $bsp_style_settings_freshness ;
    
    // Verify forum and get last active meta
    		$forum_id    = bbp_get_forum_id( $forum_id );
    		$last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
    
    		if ( empty( $last_active ) ) {
    			$reply_id = bbp_get_forum_last_reply_id( $forum_id );
    			if ( !empty( $reply_id ) ) {
    				$last_active = get_post_field( 'post_date', $reply_id );
    			} else {
    				$topic_id = bbp_get_forum_last_topic_id( $forum_id );
    				if ( !empty( $topic_id ) ) {
    					$last_active = bbp_get_topic_last_active_time( $topic_id );
    				}
    			}
    		}
    
    		$last_active = bbp_convert_date( $last_active ) ;
    		$date_format = 'j.n.Y';
    		$time_format = 'H:i';
    		$date= date_i18n( "{$date_format}", $last_active );
    		$time=date_i18n( "{$time_format}", $last_active );
    		//check the order
    		if (!empty ($bsp_style_settings_freshness['date_order'])) {
    			$first = $time ;
    			$second = $date ;
    		}
    		else {
    			$first = $date ;
    			$second = $time ;
    		}
    		$separator = (!empty ($bsp_style_settings_freshness['date_separator'] ) ? $bsp_style_settings_freshness['date_separator']  : '  ' ) ;
    		$active_time = $first.$separator.$second ;
    		return apply_filters ('bsp_change_freshness_forum' , $active_time) ;
    }
    
    //this function changes the bbp freshness data (time since) into a last post date for topics
    function bsp_change_freshness_topic ($last_active, $topic_id) {
    	global $bsp_style_settings_freshness ;
    	$topic_id = bbp_get_topic_id( $topic_id );
    
    		// Try to get the most accurate freshness time possible
    		$last_active = get_post_meta( $topic_id, '_bbp_last_active_time', true );
    		if ( empty( $last_active ) ) {
    		$reply_id = bbp_get_topic_last_reply_id( $topic_id );
    		if ( !empty( $reply_id ) ) {
    			$last_active = get_post_field( 'post_date', $reply_id );
    		} else {
    				$last_active = get_post_field( 'post_date', $topic_id );
    			}
    		}		
    		$last_active = bbp_convert_date( $last_active ) ;
    		$date_format = 'j.n.Y';
    		$time_format = 'H:i';
    		$date= date_i18n( "{$date_format}", $last_active );
    		$time=date_i18n( "{$time_format}", $last_active );
    		//check the order
    		if (!empty ($bsp_style_settings_freshness['date_order'])) {
    			$first = $time ;
    			$second = $date ;
    		}
    		else {
    			$first = $date ;
    			$second = $time ;
    		}
    		$separator = (!empty ($bsp_style_settings_freshness['date_separator'] ) ? $bsp_style_settings_freshness['date_separator']  : ' ' ) ;
    		$active_time = $first.$separator.$second ;
    		return apply_filters ('bsp_change_freshness_topic' , $active_time) ;
    }
    add_filter( 'bbp_get_forum_last_active', 'bsp_change_freshness_forum', 10, 2 );
    add_filter( 'bbp_get_topic_last_active', 'bsp_change_freshness_topic', 10, 2 );
    • This reply was modified 5 years, 4 months ago by tapiohuuhaa.
    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Seems that i must add this too with related function:
    add_action( ‘bbp_theme_before_forum_freshness_link’, ‘bsp_freshness_display_title’);

    Ok. I get the result the same as before.

    • This reply was modified 5 years, 4 months ago by tapiohuuhaa.
    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Style pack has been very helpful creating my own versions of different functionalities. I have defined buttons elsewhere. So I don’t need style pack for them.

    I added widget.php as snippet. It does have error creating valid HTML. I can fix it now.

    But seems difficult to find place, where to set ul tags around li tags.

    I addition it has span tags around h1 – there should be div tags around h1 tag.

    insteaad of span class=”bsp-st-title ” there should be div class=”bsp-st-title” W3C regards span tag around h1 as invalid HTML like it is invalid HTML if ul tags missing around li tags.

    I could copy paste better widget.php. It would be nice to get valid HTML instead original invalid HTML.

    • This reply was modified 5 years, 4 months ago by tapiohuuhaa.
    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Some propsals to fix HTML:

    
    public function widget( $args = array(), $instance = array() ) { 
    ...
    echo '<div class="bsp-st-title-container">';<br />
    if ( !empty( $settings['title'] ) ) {<br />
    echo '<div class="bsp-st-title">' . $args['before_title'] . $settings['title'] . $args['after_title'] . '</div>' ;
    echo '<ul class="info-list">';
    ...
    echo '<ul></div>'; // just before the closing }
    }

    And this for both classes:

    class bsp_Single_Topic_Widget extends WP_Widget
    class bsp_Single_Forum_Widget extends WP_Widget

    Indeed I left span tags because of existing CSS rules, where I have used span.bsp-st-title. I just regard as bad habit to put block elements inside span tags. Anyway with small fixes the plugin generates valid HTML.

    I added a style tag in order to avoid resetting CSS.
    There is empty ul-tags. Maybe in the original code ul-tags are into wrong place, because they are empty. See the error here:

    https://www.sanaristikkofoorumi.net/wordpress/wp-content/uploads/2019-11-08-13.36.33-www.sanaristikkofoorumi.net-4e9fd01caf96.png

    There is however some problems. There is empty ul tags, which relates with

    <ul>
    
    			<?php while ( $widget_query->have_posts() ) :
    <?php endwhile; ?>
    </ul>
    

    If there is no content, those should be conditional.

    Anyway the widget.php is buggy, because currently the generated HTML is invalid. I hope you have time to fix it.

    Plugin Author Robin W

    (@robin-w)

    sorry, are you suggesting an improvement to an existing widget in my style pack, or asking me to add one?

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Improve existing in order to get it generate valid HTML structure. With some modifications I get widgets.php generating valid HTML.

    I get emtpy tages off:

    		if ($widget_query->have_posts())
    		echo '<ul>'; 
    		while ( $widget_query->have_posts() ) :
    ...
     endwhile; 	
    		if ($widget_query->have_posts())
    		echo '</ul>';

    But this seems not to be the correct solution because even if I put if as commented, I didn’t get unwanted ul tags. Anyway empty ul tags should not exist.

    Indeed the end tag is in my solution in wrong place. It in the previous case would be li tags, end tag for started ul should be in different place.

    I chanded some CSS and put also bsp-st-title inside DIV element, which makes the HTML fully valid – Indeed I don’t know, if today people care, if inline element has block container.

    I just try to nest elements properly according to recommendations. I don’t create fully valid HTML, because I must use some case some element several times, which cause several same id attributes.

    • This reply was modified 5 years, 4 months ago by tapiohuuhaa.
    Plugin Author Robin W

    (@robin-w)

    the code snippet has <br /> in it on a couple of lines that will generate an error

    echo '<div class="bsp-st-title-container">';<br />
    if ( !empty( $settings['title'] ) ) {<br />

    is this an error or are you asking for the breaks to be sent ?

    Plugin Author Robin W

    (@robin-w)

    where is this div closed ?

    echo '<div class="bsp-st-title-container">';<br />

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    those become by accident – I put it into visual editor and then to text editor and I forget to remove those. linebreaks don’t belong to my proposal.

    I just proposed that the result would be something like this:
    https://www.sanaristikkofoorumi.net/wordpress/wp-content/uploads/2019-11-08-18.47.27-www.sanaristikkofoorumi.net-4f9852a4ec16.png

    Container for both the header and list, div container for header and ul container for all li tags.

    Plugin Author Robin W

    (@robin-w)

    not sure where you want this – can you give me a line no.?

    echo '<ul class="info-list">';

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    star tags for DIV are before lines 485 and 646

    start tags for UL are after lines 487 and 648

    end tags for ul and div are now after rows 557 and 715

    But as I said end tags for ul elements are in wrong place.

    It was just nice that widgets.php worked stand-alone like an independent plugin.

    • This reply was modified 5 years, 4 months ago by tapiohuuhaa.
    Plugin Author Robin W

    (@robin-w)

    thanks, I’ve released a new version

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Note that also around <span class=”bsp-la-title”> might have the same problems. Alt least that generated header inside span tag, which doesn’t look nice if you look at the source code.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Setting topic freshness date format with my own script’ is closed to new replies.