Compare commits
2 Commits
fc871dcd75
...
7f253bc452
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f253bc452 | |||
| c7b5d52197 |
@@ -25,6 +25,7 @@ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core {
|
|||||||
$this->loader->add_action( 'user_register', $this, 'add_value_after_reg' );
|
$this->loader->add_action( 'user_register', $this, 'add_value_after_reg' );
|
||||||
$this->loader->add_action( 'register_form', $this, 'registration_form' );
|
$this->loader->add_action( 'register_form', $this, 'registration_form' );
|
||||||
$this->loader->add_filter( 'registration_errors', $this, 'registration_errors', 10, 3 );
|
$this->loader->add_filter( 'registration_errors', $this, 'registration_errors', 10, 3 );
|
||||||
|
$this->loader->add_filter( 'comment_post', $this, 'validate_comment' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_custom_user_fields( $user ) {
|
public function add_custom_user_fields( $user ) {
|
||||||
@@ -76,4 +77,27 @@ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core {
|
|||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validate_comment( $id ) {
|
||||||
|
if ( empty( $_POST['company'] ) || ! empty( $_POST['company'] ) && trim( $_POST['company'] ) == '' ) {
|
||||||
|
wp_delete_comment( $id, true );
|
||||||
|
wp_die( sprintf('<strong>%s</strong>: %s',__( 'Error', 'partnerexpo-core' ),__( 'Cég megadása kötelező!', 'partnerexpo-core' ) ) );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
add_comment_meta(
|
||||||
|
$id,
|
||||||
|
'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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ class Partnerexpo_Core {
|
|||||||
'public' => true,
|
'public' => true,
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_rest' => true,
|
'show_in_rest' => true,
|
||||||
'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'author' ],
|
'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'author', 'comments' ],
|
||||||
'rewrite' => [
|
'rewrite' => [
|
||||||
'slug' => __( 'partnerek', 'partnerexpo-core' ),
|
'slug' => __( 'partnerek', 'partnerexpo-core' ),
|
||||||
'pages' => false,
|
'pages' => false,
|
||||||
@@ -225,7 +225,6 @@ class Partnerexpo_Core {
|
|||||||
];
|
];
|
||||||
|
|
||||||
register_post_type( 'pexpo_partners', $args );
|
register_post_type( 'pexpo_partners', $args );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
* Plugin Name: PartnerExpo Core
|
* Plugin Name: PartnerExpo Core
|
||||||
* Plugin URI: https://partnerexpo.eu
|
* Plugin URI: https://partnerexpo.eu
|
||||||
* Description: A PartnerEXPO oldal belső pluginja
|
* Description: A PartnerEXPO oldal belső pluginja
|
||||||
* Version: 1.1.2
|
* Version: 1.1.3
|
||||||
* Author: Juhász Levente
|
* Author: Juhász Levente
|
||||||
* Author URI: https://github.com/Duskell/
|
* Author URI: https://github.com/Duskell/
|
||||||
* License: GPL-2.0+
|
* License: GPL-2.0+
|
||||||
@@ -23,7 +23,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
define( 'PARTNEREXPO_CORE_VERSION', '1.1.2' );
|
define( 'PARTNEREXPO_CORE_VERSION', '1.1.3' );
|
||||||
|
|
||||||
function activate_partnerexpo_core() {
|
function activate_partnerexpo_core() {
|
||||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-partnerexpo-core-activator.php';
|
require_once plugin_dir_path( __FILE__ ) . 'includes/class-partnerexpo-core-activator.php';
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class Partnerexpo_Core_Public {
|
|||||||
$this->version = $version;
|
$this->version = $version;
|
||||||
|
|
||||||
add_shortcode( 'partnerexpo_searchbox', [ $this, 'searchbox_shortcode' ] );
|
add_shortcode( 'partnerexpo_searchbox', [ $this, 'searchbox_shortcode' ] );
|
||||||
|
add_shortcode( 'partnerexpo_comment_section', [ $this, 'comments_shortcode' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchbox_shortcode() {
|
public function searchbox_shortcode() {
|
||||||
@@ -55,6 +56,17 @@ class Partnerexpo_Core_Public {
|
|||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function comments_shortcode() {
|
||||||
|
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' );
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
include plugin_dir_path( __FILE__ ) . 'partials/partnerexpo-core-public-comments.php';
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
|
|
||||||
public function register_endpoint() {
|
public function register_endpoint() {
|
||||||
register_rest_route('pexpo/v1', '/query', [
|
register_rest_route('pexpo/v1', '/query', [
|
||||||
'methods' => 'GET',
|
'methods' => 'GET',
|
||||||
@@ -181,6 +193,14 @@ class Partnerexpo_Core_Public {
|
|||||||
'all'
|
'all'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
wp_register_style(
|
||||||
|
$this->plugin_name . '-comments-css',
|
||||||
|
plugin_dir_url( __FILE__ ) . 'css/comments.css',
|
||||||
|
[],
|
||||||
|
$this->version,
|
||||||
|
'all'
|
||||||
|
);
|
||||||
|
|
||||||
wp_register_style(
|
wp_register_style(
|
||||||
$this->plugin_name . '-multiselect-css',
|
$this->plugin_name . '-multiselect-css',
|
||||||
plugin_dir_url( __FILE__ ) . 'css/multiselect.css',
|
plugin_dir_url( __FILE__ ) . 'css/multiselect.css',
|
||||||
@@ -204,6 +224,15 @@ class Partnerexpo_Core_Public {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
wp_register_script(
|
||||||
|
$this->plugin_name . '-comments-js',
|
||||||
|
plugin_dir_url( __FILE__ ) . 'js/comments.js',
|
||||||
|
[],
|
||||||
|
$this->version,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
wp_register_script(
|
wp_register_script(
|
||||||
$this->plugin_name . '-multiselect-js',
|
$this->plugin_name . '-multiselect-js',
|
||||||
plugin_dir_url( __FILE__ ) . 'js/multiselect.js',
|
plugin_dir_url( __FILE__ ) . 'js/multiselect.js',
|
||||||
|
|||||||
147
public/css/comments.css
Normal file
147
public/css/comments.css
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
.pexpo-core-comments-title {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 2rem;
|
||||||
|
color: #333;
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pexpo-core-comments-body {
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px 0;
|
||||||
|
max-width: 1500px;
|
||||||
|
overflow: hidden;
|
||||||
|
-webkit-mask-image: linear-gradient(
|
||||||
|
to right,
|
||||||
|
transparent,
|
||||||
|
black 80px,
|
||||||
|
black calc(100% - 80px),
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
|
||||||
|
mask-image: linear-gradient(
|
||||||
|
to right,
|
||||||
|
transparent,
|
||||||
|
black 80px,
|
||||||
|
black calc(100% - 80px),
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
|
||||||
|
&:hover .pexpo-core-comment-groups-wrapper {
|
||||||
|
animation-play-state: paused;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pexpo-core-comment-groups-wrapper {
|
||||||
|
display: flex;
|
||||||
|
width: max-content;
|
||||||
|
will-change: transform;
|
||||||
|
animation: scrolling 20s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.pexpo-core-comment-group {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pexpo-core-comment {
|
||||||
|
position: relative;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 500px;
|
||||||
|
color: #333;
|
||||||
|
border-radius: 24px;
|
||||||
|
box-shadow: rgba(0,0,0,0.1) 5px 5px 20px 0;
|
||||||
|
padding: 20px 20px 50px 20px;
|
||||||
|
min-height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pexpo-core-comment-content {
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
max-height: 250px;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pexpo-core-comment-said_by {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #555;
|
||||||
|
padding-left: 30px;
|
||||||
|
max-height: 50px;
|
||||||
|
|
||||||
|
& p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.comment-form:has(> .pexpo-core-com-form-wrapper) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-top: 100px;
|
||||||
|
|
||||||
|
& .form-submit .submit {
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pexpo-core-com-form-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 500px;
|
||||||
|
box-shadow: #00000020 0px 5px 20px 0;
|
||||||
|
border-radius: 15px;
|
||||||
|
padding: 20px;
|
||||||
|
height: fit-content;
|
||||||
|
|
||||||
|
& .pexpo-core-com-form-title {
|
||||||
|
margin: 0 0 20px 0;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: #333;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .pexpo-core-com-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
|
||||||
|
& label {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
& input, & textarea {
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: none;
|
||||||
|
background-color: #00000010;
|
||||||
|
font-size: 1rem;
|
||||||
|
resize: vertical;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
background-color: #00000020;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@keyframes scrolling {
|
||||||
|
to {
|
||||||
|
transform: translate3d(-50%,0,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
84
public/partials/partnerexpo-core-public-comments.php
Normal file
84
public/partials/partnerexpo-core-public-comments.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?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__('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">';
|
||||||
|
for ($i = 0; $i < 2; $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 ); ?>
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
} 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' => __( '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 );
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user