replaced comment form for a custom one

This commit is contained in:
2026-03-14 19:31:10 +01:00
parent 00c23b43de
commit ef7c5ccec8
5 changed files with 115 additions and 80 deletions

View File

@@ -178,15 +178,6 @@ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core {
'company',
sanitize_text_field($_POST['company'])
);
if ( ! empty( $_POST['name'] ) && trim( $_POST['name'] ) != '' ) {
add_comment_meta(
$id,
'name',
sanitize_text_field($_POST['name'])
);
}
return true;
}
}

View File

@@ -57,12 +57,19 @@ class Partnerexpo_Core_Public {
return ob_get_clean();
}
public function comments_shortcode() {
public function comments_shortcode($atts) {
wp_enqueue_style( $this->plugin_name . '-comments-css' );
wp_enqueue_script( $this->plugin_name . '-comments-js' );
// wp_enqueue_style( $this->plugin_name . '-multiselect-css' );
// wp_enqueue_script( $this->plugin_name . '-multiselect-js' );
$atts = shortcode_atts( array(
'post_id' => get_the_ID(),
), $atts );
// This variable is now scoped and ready for the partial
$post_id = intval( $atts['post_id'] );
ob_start();
include plugin_dir_path( __FILE__ ) . 'partials/partnerexpo-core-public-comments.php';
return ob_get_clean();

View File

@@ -1,3 +1,13 @@
#pexpo-custom-comment-form {
width: 100%;
padding: 20px;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.pexpo-core-comments-title {
text-align: center;
font-size: 2rem;
@@ -105,6 +115,7 @@
border-radius: 15px;
padding: 20px;
height: fit-content;
margin-top: 50px;
& .pexpo-core-com-form-title {
margin: 0 0 20px 0;
@@ -146,6 +157,24 @@
margin: 50px 0;
}
.pexpo-core-submit-wrapper {
display: flex;
justify-content: center;
margin: 40px;
& .submit {
background-image: linear-gradient(rgb(178, 34, 34) 21%, rgb(149, 0, 0) 87%);
color: white;
border: none;
border-radius: 15px;
padding: 10px 20px;
font-size: 1rem;
cursor: pointer;
transition: background-color 0.3s ease;
}
}
@keyframes scrolling {
to {

View File

@@ -379,9 +379,11 @@ class PartnerExpoSearch {
div.className = "pexpo-core-card";
div.innerHTML = `
<div class="pexpo-core-imageWrap">
<img src="${this.escapeHtml(r.image || '')}"
alt="${this.escapeHtml(r.title)}"
style="width:100%; border-radius:10px; object-fit:cover;" />
<a href="${this.escapeHtml(r.url)}" target="_self" rel="noopener noreferrer">
<img src="${this.escapeHtml(r.image || '')}"
alt="${this.escapeHtml(r.title)}"
style="width:100%; border-radius:10px; object-fit:cover;" />
</a>
</div>
<div class="pexpo-core-cardTop">
<a href="${this.escapeHtml(r.url)}" class="pexpo-core-title">${this.escapeHtml(r.title)}</a>

View File

@@ -9,81 +9,87 @@
* @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__('Visszajelzések', '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 ) ) {
echo '<div class="pexpo-core-comment-groups-wrapper">';
if ( count( $comments ) < 3 ) {
$groups = 6 / count( $comments );
} else {
$groups = 2;
}
for ($i = 0; $i < $groups; $i++) {
echo '<div class="pexpo-core-comment-group"'.($i ? ' aria-hidden="true"' : '').'>';
<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__('Visszajelzések', '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 ) ) {
echo '<div class="pexpo-core-comment-groups-wrapper">';
if ( count( $comments ) < 3 ) {
$groups = 6 / count( $comments );
} else {
$groups = 2;
}
for ($i = 0; $i < $groups; $i++) {
echo '<div class="pexpo-core-comment-group"'.($i ? ' aria-hidden="true"' : '').'>';
foreach ($comments as $comment) {
?>
<div class="pexpo-core-comment">
<div class="pexpo-core-comment-content">
<?php echo get_comment_text( $comment ); ?>
foreach ($comments as $comment) {
?>
<div class="pexpo-core-comment">
<div class="pexpo-core-comment-content">
<?php echo get_comment_text( $comment ); ?>
</div>
<div class="pexpo-core-comment-said_by">
<?php if ( get_comment_meta( $comment->comment_ID, 'author', true ) ): ?>
<div class="pexpo-core-comment-author">
<p><?php echo get_comment_meta( $comment->comment_ID, 'author', true ); ?></p>
</div>
<div class="pexpo-core-comment-said_by">
<?php if ( get_comment_meta( $comment->comment_ID, 'name', true ) ): ?>
<div class="pexpo-core-comment-author">
<p><?php echo get_comment_meta( $comment->comment_ID, 'name', true ); ?></p>
</div>
<p>-</p>
<?php endif; ?>
<div class="pexpo-core-comment-business">
<p><?php echo get_comment_meta( $comment->comment_ID, 'company', true ); ?></p>
</div>
<p>-</p>
<?php endif; ?>
<div class="pexpo-core-comment-business">
<p><?php echo get_comment_meta( $comment->comment_ID, 'company', true ); ?></p>
</div>
</div>
<?php
}
echo '</div>';
</div>
<?php
}
echo '</div>';
} else {
?>
<p class="pexpo-core-no-comments"><?php echo esc_html__('Még nincsenek visszajelzések.', 'partnerexpo-core'); ?></p>
<?php
}
?>
</div>
<?php
$comments_args = array(
'label_submit' => __( 'Küldés', 'partnerexpo-core' ),
'title_reply' => '',
'comment_notes_after' => '',
'must_log_in' => '',
'logged_in_as' => '',
'comment_field' => '
<div class="pexpo-core-com-form-wrapper">
<h2 class="pexpo-core-com-form-title">' . _x( 'Visszajelzés küldése', 'partnerexpo_core' ) . '</h2>
<p class="pexpo-core-com-field"><label for="name">' . _x( 'Kitöltő neve', 'partnerexpo_core' ) . '</label><br />
<input type="text" id="name" name="name" aria-required="true"></p>
<p class="pexpo-core-com-field"><label for="company">' . _x( 'Cég név', 'partnerexpo_core' ) . '</label><br />
<input type="text" id="company" name="company" aria-required="true"></p>
<p class="pexpo-core-com-field"><label for="comment">' . _x( 'Hozzászólás', 'partnerexpo_core' ) . '</label><br />
<textarea id="comment" name="comment" aria-required="true" maxlength="600"></textarea></p>
</div>
',
);
comment_form( $comments_args );
echo '</div>';
} else {
?>
<p class="pexpo-core-no-comments"><?php echo esc_html__('Még nincsenek visszajelzések.', 'partnerexpo-core'); ?></p>
<?php
}
?>
</div>
</div>
<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="pexpo-custom-comment-form">
<div class="pexpo-core-com-form-wrapper">
<h2 class="pexpo-core-com-form-title"><?php echo esc_html_x( 'Visszajelzés küldése', 'partnerexpo_core' ); ?></h2>
<div class="pexpo-core-com-field">
<label for="author"><?php echo esc_html_x( 'Kitöltő neve', 'partnerexpo_core' ); ?></label><br />
<input type="text" id="author" name="author" aria-required="true" required>
</div>
<div class="pexpo-core-com-field">
<label for="company"><?php echo esc_html_x( 'Cég név', 'partnerexpo_core' ); ?></label><br />
<input type="text" id="company" name="company" aria-required="true" required>
</div>
<div class="pexpo-core-com-field">
<label for="comment"><?php echo esc_html_x( 'Hozzászólás / Visszajelzés', 'partnerexpo_core' ); ?></label><br />
<textarea id="comment" name="comment" aria-required="true" maxlength="600" required></textarea>
</div>
<div><input type="hidden" name="comment_post_ID" value="<?php echo esc_attr( $post_id ); ?>" id="comment_post_ID"></div>
<div><input type="hidden" name="comment_parent" id="comment_parent" value="0"></div>
</div>
<div class="pexpo-core-submit-wrapper">
<button type="submit" name="submit" id="submit" class="submit"><?php _e( 'Küldés', 'partnerexpo-core' ); ?></button>
</div>
</form>
</div>