Page 3 of 8

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 5:49 am
by Celauran
Well, I don't know where/how you're trying to execute this. Context matters. Is this in your comment template? Also, for staging, make sure WP_DEBUG is set to true in your wp-config

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 6:04 am
by simonmlewis
It's going in our theme folder, in the child theme, in functions.php.
The place itself that I want to action it is in the Products 'reviews' section, but I don't think that matters as it can have effect anywhere.

Sadly I cannot enable wp_debug as it is in a nginx platform and our hosts prevent us for changing that file.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 6:06 am
by Celauran
Do you not have a local dev environment?

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 6:12 am
by simonmlewis
This is not built locally, no. We did this on a special Wordpress hosting environment, with NGINX. Then the host put it on a Staging area so we can test. I can however ask if they can "unlock" the staging so we can turn on debug.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 6:24 am
by Celauran
I feel like getting local copies of the code and the DB and doing development locally would be better still. Not being able to even see debug information while you're debugging is unhelpful.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 6:32 am
by simonmlewis
Sadly I cannot even use 'Duplicator' to make a copy on my local machine. I've requested they let me adjust that file so I can switch it on.
Having said I could take a copy of another site and then add some comments and 'empty' them, but easier if I can do it on the staging one to really see it working.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 11:29 am
by Celauran
So you have no access to the database? Why not? That's a pretty big red flag to me.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 11:37 am
by simonmlewis
YES I can access the database. It's the wp_debug I cannot enable at the moment.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 11:50 am
by Celauran
So you have access to the code and the database. Why can't you run a local dev server then? Would make your life much easier.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 12:16 pm
by simonmlewis
It's got a funny setup, but leave it with me. With download everything and see if i can make it run locally.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 12:30 pm
by simonmlewis
Had a bit of success. Found otu we can add debug in a different file.
Here is what comes up when we load the homepage.

[text]Fatal error: Allowed memory size of 201326592 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vhosts/staging.site.co.uk/httpdocs/wp/wp-includes/wp-db.php on line 1841

Notice: wp_dequeue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /var/www/vhosts/staging.site.co.uk/httpdocs/wp/wp-includes/functions.php on line 4139

Notice: wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /var/www/vhosts/staging.site.co.uk/httpdocs/wp/wp-includes/functions.php on line 4139

Notice: wp_dequeue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /var/www/vhosts/staging.site.co.uk/httpdocs/wp/wp-includes/functions.php on line 4139

Notice: wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /var/www/vhosts/staging.site.co.uk/httpdocs/wp/wp-includes/functions.php on line 4139

Notice: wp_dequeue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /var/www/vhosts/staging.site.co.uk/httpdocs/wp/wp-includes/functions.php on line 4139

Notice: wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /var/www/vhosts/staging.site.co.uk/httpdocs/wp/wp-includes/functions.php on line 4139[/text]

Re: Wordpress Pagination Links - how do I modify this?

Posted: Thu Sep 14, 2017 8:27 pm
by Celauran
Fresh install, added comments with no content, made the changes I suggested, pulled this right out of comments.php

Code: Select all

        <ol class="comment-list">
            <?php
                $comments = get_comments(['post_id' => get_the_ID()]);
                $comments = array_filter($comments, function($comment) {
                    return !empty($comment->comment_content);
                });
                wp_list_comments( array(
                    'avatar_size' => 100,
                    'style'       => 'ol',
                    'short_ping'  => true,
                    'reply_text'  => twentyseventeen_get_svg( array( 'icon' => 'mail-reply' ) ) . __( 'Reply', 'twentyseventeen' ),
                ), $comments );
            ?>
        </ol>
Works precisely as I expected.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Fri Sep 15, 2017 5:31 am
by simonmlewis
This is everything in my comments.php file, I am using the Blade theme.

Code: Select all

<?php

	if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && 'comments.php' == basename( $_SERVER['SCRIPT_FILENAME'] ) ) {
		die ( esc_html__( 'This page cannot be opened directly!', 'blade' ) );
	}

	if ( post_password_required() ) {
?>
		<div class="help">
			<p class="no-comments"><?php esc_html_e( 'This post is password protected. Enter the password to view comments.', 'blade' ); ?></p>
		</div>
<?php
		return;
	}
?>

<?php if ( have_comments() ) : ?>

	<!-- Comments -->
	<div id="grve-comments" class="grve-singular-section grve-smallwidth clearfix">
		<div class="grve-container grve-padding-top-md grve-padding-bottom-md grve-border grve-border-top">
			<div class="grve-comments-header">
				<h6 class="grve-comments-number grve-text-dark">
				<?php comments_number( esc_html__( 'no comments', 'blade' ), esc_html__( '1 comment', 'blade' ), '% ' . esc_html__( 'comments', 'blade' ) ); ?>
				</h6>
				<nav class="grve-comment-nav grve-small-text">
					<ul>
				  		<li><?php previous_comments_link(); ?></li>
				  		<li><?php next_comments_link(); ?></li>
				 	</ul>
				</nav>
			</div>
			<ul>
			<?php wp_list_comments( 'type=comment&callback=blade_grve_comments' ); ?>
			</ul>
		</div>
	</div>
	<!-- End Comments -->

<?php endif; ?>


<?php if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>

	<div id="grve-comments" class="grve-singular-section clearfix">
		<div class="grve-container grve-padding-top-md grve-padding-bottom-md grve-border grve-border-top">
			<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'blade' ); ?></p>
		</div>
	</div>

<?php endif; ?>


<?php if ( comments_open() ) : ?>

<?php
		$commenter = wp_get_current_commenter();
		$req = get_option( 'require_name_email' );

		$args = array(
			'id_form'           => 'commentform',
			'id_submit'         => 'grve-comment-submit-button',
			'title_reply'       => esc_html__( 'Leave a Reply', 'blade' ),
			'title_reply_to'    => esc_html__( 'Leave a Reply to', 'blade' ) . ' %s',
			'cancel_reply_link' => esc_html__( 'Cancel Reply', 'blade' ),
			'label_submit'      => esc_html__( 'Submit Comment', 'blade' ),
			'submit_button'     => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',

			'comment_field' =>
				'<div class="grve-form-textarea grve-border">'.
				'<textarea style="resize:none;" id="comment" name="comment" placeholder="' . esc_attr__( 'Your Comment Here...', 'blade' ) . '" cols="45" rows="15" aria-required="true">' .
				'</textarea></div>',

			'must_log_in' =>
				'<p class="must-log-in">' . esc_html__( 'You must be', 'blade' ) .
				'<a href="' .  wp_login_url( get_permalink() ) . '">' . esc_html__( 'logged in', 'blade' ) . '</a> ' . esc_html__( 'to post a comment.', 'blade' ) . '</p>',

			'logged_in_as' =>
				'<div class="logged-in-as grve-small-text">' .  esc_html__('Logged in as','blade') .
				'<a href="' . admin_url( 'profile.php' ) . '"> ' . $user_identity . '</a>. ' .
				'<a href="' . wp_logout_url( get_permalink() ) . '" title="' . esc_attr__( 'Log out of this account', 'blade' ) . '"> ' . esc_html__( 'Log out', 'blade' ) . '</a></div>',

			'comment_notes_before' => '',
			'comment_notes_after' => '' ,

			'fields' => apply_filters(
				'comment_form_default_fields',
				array(
					'author' =>
						'<div class="grve-form-input grve-border">' .
						'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '"' .
						' placeholder="' . esc_attr__( 'Name', 'blade' ) . ' ' . ( $req ? esc_attr__( '(required)', 'blade' ) : '' ) . '" />' .
						'</div>',

					'email' =>
						'<div class="grve-form-input grve-border">' .
						'<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '"' .
						' placeholder="' . esc_attr__( 'E-mail', 'blade' ) . ' ' . ( $req ? esc_attr__( '(required)', 'blade' ) : '' ) . '" />' .
						'</div>',

					'url' =>
						'<div class="grve-form-input grve-border">' .
						'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '"' .
						' placeholder="' . esc_attr__( 'Website', 'blade' )  . '" />' .
						'</div>',
					)
				),
		);
?>
		<div id="grve-comment-form" class="grve-singular-section grve-smallwidth clearfix">
			<div class="grve-container grve-padding-top-md grve-padding-bottom-md">

			<?php
				//Use comment_form() with no parameters if you want the default form instead.
				comment_form( $args );
			?>
			</div>
		</div>


<?php endif;

//Omit closing PHP tag to avoid accidental whitespace output errors.

Re: Wordpress Pagination Links - how do I modify this?

Posted: Fri Sep 15, 2017 5:46 am
by Celauran
Is there a question here? You can see wp_list_comments there at the bottom, you can see the changes I made around that in my example. Have you tried that? Is it not working?

Re: Wordpress Pagination Links - how do I modify this?

Posted: Fri Sep 15, 2017 5:50 am
by simonmlewis
Can I step back a moment please. So what you sent me this morning first, was that new code to be added, or an example of comments.php, along with the code you sent that I said, breaks my staging site?