added comments shortcode and form for it

This commit is contained in:
2026-03-11 20:21:28 +01:00
parent fc871dcd75
commit c7b5d52197
5 changed files with 87 additions and 5 deletions

View File

@@ -0,0 +1,63 @@
<?php
/**
* Provides the code for the comments shortcode
*
* @link https://github.com/Duskell
* @since 1.1.4
*
* @package Partnerexpo_Core
* @subpackage Partnerexpo_Core/public/partials
*/
?>
<div class="pexpo-core-root pexpo-core-shell" id="pexpo-core-comments-shell">
<div class="pexpo-core-comments" id="pexpo-core-comments">
<div class="pexpo-core-comments-header">
<h2 class="pexpo-core-comments-title"><?php echo esc_html__('Hozzászólások', 'partnerexpo-core'); ?></h2>
</div>
<div class="pexpo-core-comments-body" id="pexpo-core-comments-body">
<?php
$comments = get_comments([
'post_id' => get_the_ID(),
'status' => 'approve',
]);
if ( ! empty( $comments ) ) {
foreach ( $comments as $comment ) {
?>
<div class="pexpo-core-comment">
<div class="pexpo-core-comment-author">
<?php echo get_comment_meta( $comment, 'company', true ); ?>
</div>
<div class="pexpo-core-comment-content">
<?php echo get_comment_text( $comment ); ?>
</div>
</div>
<?php
}
} else {
?>
<p class="pexpo-core-no-comments"><?php echo esc_html__('Még nincsenek hozzászólások.', 'partnerexpo-core'); ?></p>
<?php
}
?>
</div>
<?php
$comments_args = array(
'label_submit' => __( 'Send', 'partnerexpo-core' ),
'title_reply' => __( 'Write a Reply or Comment', 'partnerexpo-core' ),
'comment_notes_after' => '',
'must_log_in' => '',
'logged_in_as' => '',
'comment_field' => '
<p class="comment-form-comment"><label for="company">' . _x( 'Company', 'partnerexpo_core' ) . '</label><br />
<input type="text" id="company" name="company" aria-required="true"></textarea></p>
<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'partnerexpo_core' ) . '</label><br />
<textarea id="comment" name="comment" aria-required="true"></textarea></p>
',
);
comment_form( $comments_args );
?>
</div>
</div>