PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Oct 22, 2018 6:15 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 115 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8  Next
Author Message
PostPosted: Mon Sep 18, 2017 2:58 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
Wow what a job there. The difficulty I have is in comments.php, I have this:
Syntax: [ Download ] [ Hide ]
                        <ul>
                        <?php
                $comments = get_comments(['post_id' => get_the_ID()]);
                $comments = array_filter($comments, function($comment) {
                    return !empty($comment->comment_content);
                });
               
                        wp_list_comments( 'type=comment&callback=blade_grve_comments', $comments); ?>
                        </ul>


So not an "ol", tho that's just semantics, but not the rest of the stuff in that tag either.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 3:04 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
It also doesn't like starting in the function...

Syntax: [ Download ] [ Hide ]
$defaults['base'] = <span style='color:blue'

The <span. that first < is not liked.

Syntax: [ Download ] [ Hide ]
Parse error: syntax error, unexpected '<' in /var/www/vhosts/staging.site.co.uk/httpdocs/wp-content/themes/blade-child/functions.php on line 202
 

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 5:16 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
I think that's something that got mangled by the forum software, and I can't seem to post it. That line should be the same as in the original paginate_comments_links function.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 5:29 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
can you send me a screenshot of what it should be please? I guess there are double quotes in there?
I can see you have added smurf stuff for fun. Which I guess is to be replaced with 1, 2... etc.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 5:40 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
That's not me having a laugh, that's the forum software filtering out what it thinks is either spam or malicious code. Can't upload a screenshot for some reason, so here's a link: https://imgur.com/gFNIUpG

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 5:46 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
Oh wow yes I see.

so I added it, and no errors now, but the pagination still appears.
This is the actual code is generates around each number:

Syntax: [ Download ] [ Hide ]
<nav class="woocommerce-pagination"><ul class='page-numbers'>
        <li><span class='page-numbers current'>1</span></li>
        <li><a class='page-numbers' href='http://staging.site.co.uk/product/red-shirt/comment-page-2/#comments'>2</a></li>
        <li><a class='page-numbers' href='http://staging.site.co.uk/product/red-shirt/comment-page-3/#comments'>3</a></li>
        <li><span class="page-numbers dots">&hellip;</span></li>
        <li><a class='page-numbers' href='http://staging.site.co.uk/product/red-shirt/comment-page-10/#comments'>10</a></li>
        <li><a class="next page-numbers" href="http://staging.site.co.uk/product/red-shirt/comment-page-2/#comments">&rarr;</a></li>
</ul>
</nav>

It's doing this when there are no comments (with content).

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 5:54 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
The pagination should presumably still appear, just the number of pages should be reduced to the correct amount. I took a fresh install of WordPress, added 400 comments, some with content, some without, and the code I listed now shows 11 pages (20 comments per page) instead of 21, which would be the norm. Does that not line up with what you're seeing? (With adjusted numbers, obviously)

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 6:00 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
In theory this page should show NO page numbers at all
There are 272 star ratings (no comment text) comments. So the Reviews themselves are empty. But shows the pagination.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 6:01 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
Interesting... Have you inspected the $comments array? Does it contain anything?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 6:07 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
It's probably worth saying too that in the view source is has <ul class='page-numbers'> but in comments.php it doesn't have that.
And if I add "<ul class='fred'>", it doesnt render that.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 6:40 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
simonmlewis wrote:
It's probably worth saying too that in the view source is has <ul class='page-numbers'> but in comments.php it doesn't have that.

That is useful. Tells us this isn't being rendered by comments.php, but some other file. See if you can track down where these comments are being generated from and we can work from there. Time for me to go to work now, so I probably won't be able to look at this again until tonight.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 6:54 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
Will do - leave it with me.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 8:23 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
Found the file. IT's in out child theme for single-product-reviews.php.

This is the HTML part:
Syntax: [ Download ] [ Hide ]
                        <ol class="commentlist">
                                <?php wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', array( 'callback' => 'woocommerce_comments', 'end-callback' => 'jbbg_woocommerce_comments_end' ) ) ); ?>
                        </ol>


I tried this but it kept the page number and moved it under comments:
Syntax: [ Download ] [ Hide ]
                        <ol class="commentlist">
                                <?php
                               
                                        $comments = get_comments(['post_id' => get_the_ID()]);
                $comments = array_filter($comments, function($comment) {
                    return !empty($comment->comment_content);
                });
               
                                 wp_list_comments( apply_filters( 'woocommerce_product_review_list_args',$comments, array( 'callback' => 'woocommerce_comments', 'end-callback' => 'jbbg_woocommerce_comments_end',  ) ) ); ?>
                        </ol>
 

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 11:29 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
Looks like you've added $comments to the wrong place in the wp_list_comments call. It needs to be the second argument, so right before the last closing parenthesis. Don't forget you'll also need to swap out calls to pagination methods for the new ones.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 18, 2017 11:35 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4425
Location: United Kingdom
Do you mean to add $comments before the final ) ?
What do you mean about swapping out calls ??

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 115 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group