'', 'layout' => 'layout1', /* ============================ Post Comment Settings ============================*/ // Comments Form Heading 'replyHeading' => true, 'leaveRepText' => 'Leave a Reply', /* ============================ Comments Form Input ============================*/ 'inputPlaceHolder' => 'Express your thoughts, idea or write a feedback by clicking here & start an awesome comment', /* ============================ Comments Form label style ============================*/ 'inputLabel' => true, 'cmntInputText' => "Comment's", 'nameInputText' => 'Name', 'emailInputText' => 'Email', 'webInputText' => 'Website Url', 'cookiesEnable' => true, 'cookiesText' => 'Save my name, email, and website in this browser for the next time I comment.', /* ============================ Submit Button Style ============================*/ 'subBtnText' => 'Post Comment', /* ============================ Comment Reply Style ============================*/ // Title and total Comment Count 'replyText' => 'Comments Text', 'commentCount' => true, // -------------------------- // Advanced Settings // -------------------------- 'advanceId' => '', 'advanceZindex' => '', 'hideExtraLarge' => false, 'hideDesktop' => false, 'hideTablet' => false, 'hideMobile' => false, 'advanceCss' => '', ); } public function register() { register_block_type( 'ultimate-post/post-comments', array( 'editor_script' => 'ultp-blocks-editor-script', 'editor_style' => 'ultp-blocks-editor-css', 'render_callback' => array( $this, 'content' ), ) ); } public function content( $attr, $noAjax ) { $attr = wp_parse_args( $attr, $this->get_attributes() ); $block_name = 'post-comments'; $wrapper_before = $wrapper_after = $wrapper_content = ''; if ( is_single() ) { $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : ''; $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : ''; $attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : ''; $attr['blockId'] = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : ''; $attr['layout'] = sanitize_html_class( $attr['layout'] ); $allowed_html_tags = ultimate_post()->ultp_allowed_html_tags(); $attr['nameInputText'] = wp_kses( $attr['nameInputText'], $allowed_html_tags ); $attr['emailInputText'] = wp_kses( $attr['emailInputText'], $allowed_html_tags ); $attr['webInputText'] = wp_kses( $attr['webInputText'], $allowed_html_tags ); $attr['cmntInputText'] = wp_kses( $attr['cmntInputText'], $allowed_html_tags ); $attr['cookiesText'] = wp_kses( $attr['cookiesText'], $allowed_html_tags ); $attr['inputPlaceHolder'] = wp_kses( $attr['inputPlaceHolder'], $allowed_html_tags ); $attr['subBtnText'] = wp_kses( $attr['subBtnText'], $allowed_html_tags ); $attr['leaveRepText'] = wp_kses( $attr['leaveRepText'], $allowed_html_tags ); $attr['replyText'] = wp_kses( $attr['replyText'], $allowed_html_tags ); $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); $auth_label = $attr['inputLabel'] ? '' : ''; $email_label = $attr['inputLabel'] ? '' : ''; $url_label = $attr['inputLabel'] ? '' : ''; $comment_label = $attr['inputLabel'] ? '' : ''; $cookies_label = $attr['cookiesEnable'] ? '' : ''; $comments_args = array( 'comment_field' => '
' . wp_kses_post( $comment_label ) . '
', 'fields' => apply_filters( 'comment_form_default_fields', array( 'author' => '
' . wp_kses_post( $auth_label ) . '
', 'email' => '
' . wp_kses_post( $email_label ) . '
', 'url' => '
' . wp_kses_post( $url_label ) . '
', 'cookies' => $cookies_label, ) ), 'class_submit' => 'ultp-comment-btn', 'comment_notes_after' => '', 'submit_button' => '', 'class_form' => 'ultp-comment-form', 'title_reply' => ( $attr['replyHeading'] ? '
' . $attr['leaveRepText'] . '
' : '' ), 'class_container' => 'ultp-comment-form-container', ); $arg = array( 'walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'comment', 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => true, 'reverse_children' => '', 'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml', 'short_ping' => false, 'echo' => true, ); $moderation_enable = get_option( 'comment_moderation' ); $comments = get_comments( array( 'post_id' => get_the_ID(), 'status' => $moderation_enable ? 'approve' : 'all', ) ); $wrapper_before .= '
'; $wrapper_before .= '
'; if ( $attr['commentCount'] && count( $comments ) > 0 ) { $wrapper_content .= '
'; $wrapper_content .= count( $comments ) . ' ' . $attr['replyText']; $wrapper_content .= '
'; } $wrapper_content .= '
'; ob_start(); wp_list_comments( $arg, $comments ); $wrapper_content .= ob_get_clean(); $wrapper_content .= '
'; $wrapper_content .= '
'; ob_start(); comment_form( $comments_args ); $wrapper_content .= ob_get_clean(); $wrapper_content .= '
'; $wrapper_after .= '
'; $wrapper_after .= '
'; } return $wrapper_before . $wrapper_content . $wrapper_after; } }