#186 – Hide The Time on Comment's Date.

Posted in ‘weeblrAMP’
This is a public ticket. Everybody will be able to see its contents. Only enter usernames, passwords or any other sensitive information in the Private information field.
Thursday, 05 December 2019 20:02 UTC
flashwebcenter
Hello,
I am still having more fun with this plugin and I am trying to hide the comment's date. I was able to hide the date in function.php but the problem is you have the word 'at'. So the date was printed as (May 25, 2019 at).
I looked around and it is printed in ../weeblramp/integration/woocommerce/commentwalker.php on line 64 you have the date and time printed and in one html tag <time>. Also I could not override this file in my theme. The solution I came with is to change the code so we can have ability to hide it.
If you please change line 64 from
printf( __( '%1$s at %2$s', 'weeblramp' ), get_comment_date( '', $comment ), get_comment_time() );
to
printf( __( '%1$s %2$s', 'weeblramp' ), "<span class='comment-date'>" . get_comment_date( '', $comment ) . "</span>", "<span class='comment-time'> at " . get_comment_time() . "</span>");


This is the html output.
<div class="comment-metadata">
      <time>
        <span class="comment-date">May 25, 2019</span>
       <span class="comment-time"> at 10:54 am</span>                    
     </time>
</div>

Now I can remove the comment time in function.php and hide the word 'at' by css.
Friday, 06 December 2019 13:40 UTC
wb_weeblrpress
Hi

Thanks for the suggestion, happy you are having fun!

We just used the standard WP/WC comments/review output. But indeed what you suggest is more flexible. Maybe it'd be a bit more flexible to just add a filter for this. So that the output could be overriden (with a template override or through a filter).

I did a test version with 2 new filters: one for date/time and one for author name:

- You can download a modified version from this online folder. The password is weeblramp
- Install over your current version and you can then add the following filters.
- You can then add filters in src/main/wp-content/themes/{your-child-theme}/weeblramp/functions.php as follow:

<?php
/**
 * Sample frontend functions.php for weeblrAMP
 */

// Security check to ensure this file is being included by a parent file.
defined( 'WEEBLRAMP_EXEC' ) || die;

add_filter(
	'weeblramp_wc_review_date_time_html',
	function ( $datetimeHtml, $comment ) {

		//$datetimeHtml = str_replace(
		//	'at',
		//	'at about',
		//	$datetimeHtml
		//);

                // only output the date
		$datetimeHtml = get_comment_date(
			'',
			$comment
		);

		return $datetimeHtml;
	},
	10,
	2
);

add_filter(
	'weeblramp_wc_review_author_html',
	function ( $authorHtml, $comment ) {

		$authorHtml = str_replace(
			'says:',
			'commented:',
			$authorHtml
		);

		return $authorHtml;
	},
	10,
	2
);



let me know how it goes,

Best regards

 
Friday, 06 December 2019 14:52 UTC
flashwebcenter
Hello,
Thank you for the update. I don't have a child theme installed. I have a custom theme (Horus). I have a folder crated inside the installed theme named weeblramp. I added all the customized template as directed in https://www.weeblrpress.com/documentation/products.weeblramp/1/going-further/advanced-customization/template-overrides.html.
I added functions.php inside ../wp-content/themes/horus/weeblramp/functions.php but it did not work. Then I added the code to ./wp-content/themes/horus/functions.php it worked.

In www.your-website-dot-com/wp-admin/admin.php?page=weeblramp-settings I have under Theme management Disable theme on AMP pages is unchecked. If I disable the theme I can't override any weeblramp template.

Example:
I have ../wp-content/themes/horus/weeblramp/layouts/weeblramp/frontend/amp/contents/wc_price.php in my theme. If I check Disable theme on AMP pages I will not be able to see any updates I have in the file.

Not sure if this is what it should be. If you want to override any template you can't disable the main theme.
Friday, 06 December 2019 19:27 UTC
wb_weeblrpress
Hi

Thank you for your detailed report. I found a flaw in the logic that handle loading the custom functions.php and template override. Namely, if a theme change happened at some point after weeblrAMP has been enabled, it was not properly taken into account and so:

- if you made some changes in the theme functions.php, it was loaded as long as the theme was not disabled
- if you made some changes in {theme}/weeblramp.php/functions.php or in a template override, weeblrAMP would keep searchin for that in the previously enabled theme, not in the current one.

I have made a new version (download it from the same source) which fixes that problem. It will load the {active_theme}/weeblramp/xxxx code you create regardless of any theme change.

Note that all changes related to weeblrAMP should be made in the {active_theme}/weeblramp folder as this is the only one that is certain to be loaded on AMP pages (that is unless a bug prevent it of course).

Note that the functions.php file in your theme will only be loaded if you do not disable the theme on AMP.

I don't have a child theme installed. I have a custom theme (Horus)
That's fine. IF you used a child theme, the weeblrAMP customizations would better be stored in that child theme. However in that case, we still load the "parent" theme {parent_theme}/weeblramp/functions.php file.

Let me know.

Best regards
 
Friday, 06 December 2019 22:45 UTC
flashwebcenter
Hello,
Thank you very much for the updates. I disabled the theme in Theme management and I was able to load the custom files. Thank you!
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.