PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Nov 22, 2017 4:26 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 115 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 8  Next
Author Message
PostPosted: Thu Sep 14, 2017 5:49 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6391
Location: Montreal, Canada
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

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 6:04 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
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.

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


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 6:06 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6391
Location: Montreal, Canada
Do you not have a local dev environment?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 6:12 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
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.

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


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 6:24 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6391
Location: Montreal, Canada
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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 6:32 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
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.

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


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 11:29 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6391
Location: Montreal, Canada
So you have no access to the database? Why not? That's a pretty big red flag to me.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 11:37 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
YES I can access the database. It's the wp_debug I cannot enable at the moment.

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


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 11:50 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6391
Location: Montreal, Canada
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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 12:16 pm 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
It's got a funny setup, but leave it with me. With download everything and see if i can make it run locally.

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


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 12:30 pm 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
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.

Syntax: [ Download ] [ Hide ]
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

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


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 8:27 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6391
Location: Montreal, Canada
Fresh install, added comments with no content, made the changes I suggested, pulled this right out of comments.php

Syntax: [ Download ] [ Hide ]
        <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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Fri Sep 15, 2017 5:31 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
This is everything in my comments.php file, I am using the Blade theme.

Syntax: [ Download ] [ Hide ]
<?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.

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


Top
 Profile  
 
PostPosted: Fri Sep 15, 2017 5:46 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6391
Location: Montreal, Canada
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?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Fri Sep 15, 2017 5:50 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4359
Location: United Kingdom
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?

_________________
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, 2, 3, 4, 5, 6 ... 8  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 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