added comments shortcode and form for it
This commit is contained in:
@@ -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( 'register_form', $this, 'registration_form' );
|
||||
$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 ) {
|
||||
@@ -76,4 +77,11 @@ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core {
|
||||
|
||||
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' ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,15 +217,14 @@ class Partnerexpo_Core {
|
||||
'public' => true,
|
||||
'has_archive' => false,
|
||||
'show_in_rest' => true,
|
||||
'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'author' ],
|
||||
'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'author', 'comments' ],
|
||||
'rewrite' => [
|
||||
'slug' => __( 'partnerek', 'partnerexpo-core' ),
|
||||
'pages' => false,
|
||||
]
|
||||
];
|
||||
|
||||
register_post_type( 'pexpo_partners', $args );
|
||||
|
||||
register_post_type( 'pexpo_partners', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Plugin Name: PartnerExpo Core
|
||||
* Plugin URI: https://partnerexpo.eu
|
||||
* Description: A PartnerEXPO oldal belső pluginja
|
||||
* Version: 1.1.2
|
||||
* Version: 1.1.3
|
||||
* Author: Juhász Levente
|
||||
* Author URI: https://github.com/Duskell/
|
||||
* License: GPL-2.0+
|
||||
@@ -23,7 +23,7 @@ if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
define( 'PARTNEREXPO_CORE_VERSION', '1.1.2' );
|
||||
define( 'PARTNEREXPO_CORE_VERSION', '1.1.3' );
|
||||
|
||||
function activate_partnerexpo_core() {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-partnerexpo-core-activator.php';
|
||||
|
||||
@@ -42,6 +42,7 @@ class Partnerexpo_Core_Public {
|
||||
$this->version = $version;
|
||||
|
||||
add_shortcode( 'partnerexpo_searchbox', [ $this, 'searchbox_shortcode' ] );
|
||||
add_shortcode( 'partnerexpo_comment_section', [ $this, 'comments_shortcode' ] );
|
||||
}
|
||||
|
||||
public function searchbox_shortcode() {
|
||||
@@ -55,6 +56,17 @@ class Partnerexpo_Core_Public {
|
||||
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() {
|
||||
register_rest_route('pexpo/v1', '/query', [
|
||||
'methods' => 'GET',
|
||||
|
||||
63
public/partials/partnerexpo-core-public-comments.php
Normal file
63
public/partials/partnerexpo-core-public-comments.php
Normal 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>
|
||||
Reference in New Issue
Block a user