'; $author_portfolio_comment_field['email'] = ''; $author_portfolio_comment_field['url'] = ' '; return $author_portfolio_comment_field; } add_filter( 'comment_form_defaults', 'author_portfolio_comment_default_form' ); function author_portfolio_comment_default_form( $default_form ) { $default_form['comment_field'] = ''; $default_form['submit_button'] = ''; $default_form['comment_notes_before'] = wp_nonce_field( 'author_portfolio_comment', 'author_portfolio_comment_nonce', true, false ); $default_form['title_reply'] = esc_attr__( 'Leave A Comment', 'author-portfolio' ); $default_form['title_reply_before'] = '

'; $default_form['title_reply_after'] = '

'; return $default_form; } function author_portfolio_comment_form_structure( $fields ) { $author_field = $fields['author']; $email_field = $fields['email']; if (function_exists('is_woocommerce') && !is_woocommerce()) { $url_field = $fields['url']; } $comment_field = $fields['comment']; $cookies_field = $fields['cookies']; unset( $fields['author'] ); unset( $fields['email'] ); unset( $fields['url'] ); unset( $fields['comment'] ); unset( $fields['cookies'] ); $fields['author'] = $author_field; $fields['email'] = $email_field; if (function_exists('is_woocommerce') && !is_woocommerce()) { $fields['url'] = $url_field; } $fields['comment'] = $comment_field; $fields['cookies'] = $cookies_field; return $fields; } add_filter( 'comment_form_fields', 'author_portfolio_comment_form_structure' ); if ( ! function_exists( 'author_portfolio_comment_list' ) ) : /** * Template for displaying comments and pingbacks. * * @since Shape 1.0 */ function author_portfolio_comment_list( $comment, $args, $depth ) { $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; $add_below = ( 'div' === $args['style'] ) ? 'comment' : 'div-comment'; $has_children_class = empty( $args['has_children'] ) ? '' : 'parent'; echo sprintf( '<%1$s %2$s id="comment-%3$d">', esc_attr( $tag ), comment_class( $has_children_class, null, null, false ), get_comment_ID() ); if ( 'div' === $args['style'] ) { echo '
'; } ?>
'lazyload', 'loading' => 'lazy' ) ); } ?>
comment_approved ) : ?>

comment_ID ) && ( time() - strtotime( $comment->comment_date_gmt ) < 300 ) ) { echo '
'; edit_comment_link( esc_html__( 'Edit', 'author-portfolio' ), '', '' ); echo '
'; } comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
', 'after' => '
', ) ) ); ?>
'; } echo ""; } endif; add_action( 'wp_insert_comment', 'author_portfolio_clear_comment_count_transient', 10, 2 ); function author_portfolio_clear_comment_count_transient( $comment_id, $comment ) { if ( $comment->comment_approved == 1 ) { delete_transient( 'author_portfolio_comment_count_' . $comment->comment_post_ID ); } } add_filter( 'preprocess_comment', 'author_portfolio_sanitize_comment_data' ); function author_portfolio_sanitize_comment_data( $comment_data ) { $comment_data['comment_author'] = sanitize_text_field( $comment_data['comment_author'] ); $comment_data['comment_author_email'] = sanitize_email( $comment_data['comment_author_email'] ); $comment_data['comment_author_url'] = esc_url_raw( $comment_data['comment_author_url'] ); $comment_data['comment_content'] = wp_kses_post( $comment_data['comment_content'] ); return $comment_data; } add_action( 'pre_comment_on_post', 'author_portfolio_verify_comment_nonce' ); function author_portfolio_verify_comment_nonce() { if ( ! isset( $_POST['author_portfolio_comment_nonce'] ) || ! wp_verify_nonce( $_POST['author_portfolio_comment_nonce'], 'author_portfolio_comment' ) ) { wp_die( esc_html__( 'Security check failed. Please try again.', 'author-portfolio' ) ); } }