✏️ 正在编辑: blogcomments.php
路径:
/home/qyel0117/public_html/wp-content/themes/semplice7/editor/modules/blogcomments.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php // namespace namespace Semplice\Editor\Modules; // use use Semplice\Editor; use Semplice\Helper\Color; use WP_Query; // ----------------------------------------- // module // ----------------------------------------- class BlogcommentsModule extends Editor { public $module; // ----------------------------------------- // constructor // ----------------------------------------- public function __construct() { $this->module = array( 'html' => '', 'css' => '', ); } // ----------------------------------------- // output editor // ----------------------------------------- public function editor($id, $values) { // extract options extract( shortcode_atts( array( 'comments_visibility' => 'visible' ), $values['options'] ) ); // define outpout $output = ''; // is editor? if($comments_visibility != 'hidden' && !self::$is_editor) { // get post id $post_id = get_the_ID(); // args $args = array( 'p' => $post_id, 'posts_per_page' => 1, 'post_type' => 'post', ); // get posts $query = new WP_Query($args); // check if posts there if($query->have_posts()) { while($query->have_posts()) { // the post $query->the_post(); // get comments $comments = get_comments('post_id=' . get_the_ID() . '&orderby=comment_parent&status=approve'); // output $output = $this->get_comments('custom', $comments, $values['options']); } } } else { $output = $this->customize_html($values['options']); } // visiblity if($comments_visibility != 'hidden' || self::$is_editor) { $output = ' <div class="is-content"> <div class="blogposts-comments"> ' . $output . ' </div> </div> '; // is frontend? if(!self::$is_editor) { $output = '<div id="comments">' . $output . '</div>'; } } else { $output = ''; } // add to html output $this->module['html'] = $output; // add to css $this->module['css'] = $this->css($values['options'], '#' . $id, false); // output return $this->module; } // ----------------------------------------- // output frontend // ----------------------------------------- public function frontend($id, $values) { // same as editor return $this->editor($id, $values); } // ----------------------------------------- // get css // ----------------------------------------- public function css($options, $prefix, $is_admin) { // css $css = ''; // comment bg color if(isset($options['comment_bg_color'])) { $css .= $prefix . ' { background-color: ' . $options['comment_bg_color'] . '; }'; } // comment title color if(isset($options['comment_title_color'])) { $css .= $prefix . ' .comments-title { color: ' . $options['comment_title_color'] . '; }'; } // comment title alignment if(isset($options['comment_title_align'])) { $css .= $prefix . ' .comments-title { text-align: ' . $options['comment_title_align'] . '; }'; } // comment title font size if(isset($options['comment_title_font_size'])) { $css .= $prefix . ' .comments-title { font-size: ' . $options['comment_title_font_size'] . '; }'; } // comment author font color if(isset($options['comment_author_color'])) { $css .= $prefix . ' .comments .comment .comment-author cite, ' . $prefix . ' .comments .comment .comment-author cite a { color: ' . $options['comment_author_color'] . '; }'; } // comment author hover if(isset($options['comment_author_mouseover_color'])) { $css .= $prefix . ' .comments .comment .comment-author cite a:hover { color: ' . $options['comment_author_mouseover_color'] . '; }'; } // comment date font color if(isset($options['comment_date_color'])) { $css .= $prefix . ' .comments .comment .comment-meta a { color: ' . $options['comment_date_color'] . '; }'; } // comment date hover if(isset($options['comment_date_mouseover_color'])) { $css .= $prefix . ' .comments .comment .comment-meta a:hover { color: ' . $options['comment_date_mouseover_color'] . '; }'; } // comment font color if(isset($options['comment_content_color'])) { $css .= $prefix . ' .comments .comment .comment-content { color: ' . $options['comment_content_color'] . '; }'; } // comment font size if(isset($options['comment_content_font_size'])) { $css .= $prefix . ' .comments .comment .comment-content { font-size: ' . $options['comment_content_font_size'] . '; }'; } // comment line height if(isset($options['comment_content_line_height'])) { $css .= $prefix . ' .comments .comment .comment-content { line-height: ' . $options['comment_content_line_height'] . '; }'; } // comment divider color if(isset($options['comment_content_divider_color'])) { $css .= $prefix . ' .comments .comment, ' . $prefix . ' .comments .comment .depth-2, ' . $prefix . ' .comments .comment .depth-3 { border-color: ' . $options['comment_content_divider_color'] . '; }'; } // comment reply bg color if(isset($options['comment_reply_bg_color'])) { $css .= $prefix . ' .comments .comment .reply a, ' . $prefix . ' #respond #reply-title #cancel-comment-reply-link { background-color: ' . $options['comment_reply_bg_color'] . '; }'; } // comment reply color if(isset($options['comment_reply_color'])) { $css .= $prefix . ' .comments .comment .reply a, ' . $prefix . ' #respond #reply-title #cancel-comment-reply-link { color: ' . $options['comment_reply_color'] . '; }'; } // comment reply border if(isset($options['comment_reply_border_color'])) { $css .= $prefix . ' .comments .comment .reply a, ' . $prefix . ' #respond #reply-title #cancel-comment-reply-link { border-color: ' . $options['comment_reply_border_color'] . '; }'; } // respond color if(isset($options['comment_respond_color'])) { $css .= $prefix . ' #respond #reply-title, ' . $prefix . ' #respond #reply-title a { color: ' . $options['comment_respond_color'] . '; }'; } // form open $css .= ' ' . $prefix . ' form#commentform .comment-input input, ' . $prefix . ' form#commentform textarea, ' . $prefix . ' form#commentform .comment-input input:hover, ' . $prefix . ' form#commentform textarea:hover, ' . $prefix . ' form#commentform .comment-input input:focus, ' . $prefix . ' form#commentform textarea:focus { '; // form bg color if(isset($options['comment_form_bg_color'])) { $css .= Color::bg_css($options['comment_form_bg_color'], $is_admin, false); } // form color if(isset($options['comment_form_color'])) { $css .= 'color: ' . $options['comment_form_color'] . ';'; } // border color if(isset($options['comment_form_border_color'])) { $css .= 'border-color: ' . $options['comment_form_border_color'] . ';'; } // form close $css .= '}'; // placeholder color if(isset($options['comment_form_placeholder_color'])) { $css .= $prefix . ' form#commentform .comment-input input::placeholder, ' . $prefix . ' form#commentform .comment-input textarea::placeholder { color: ' . $options['comment_form_placeholder_color'] . '; }'; } // submit open $css .= ' ' . $prefix . ' form#commentform #submit, ' . $prefix . ' form#commentform #submit:hover, ' . $prefix . ' form#commentform #submit:focus { '; // form bg color if(isset($options['comment_submit_bg_color'])) { $css .= Color::bg_css($options['comment_submit_bg_color'], $is_admin, false); } // form color if(isset($options['comment_submit_color'])) { $css .= 'color: ' . $options['comment_submit_color'] . ';'; } // form color if(isset($options['comment_submit_border_color'])) { $css .= 'border-color: ' . $options['comment_submit_border_color'] . ';'; } // submit close $css .= '}'; // for the blogcomments module if($prefix != '#comments') { // paddings $paddings = array( 'comment_title_padding_top' => '5rem', 'comment_title_padding_bottom' => '3.333333333333333rem', ); // iterate foreach ($paddings as $padding => $val) { if(isset($options[$padding])) { $paddings[$padding] = $options[$padding]; } } // add to css $css .= $prefix . ' .comments-title { padding: ' . $paddings['comment_title_padding_top'] . ' 0rem ' . $paddings['comment_title_padding_bottom'] . ';}'; } // ret return $css; } // ----------------------------------------- // semplice comment html // ----------------------------------------- public function comments_html($comment, $args, $depth){ // get options extract(shortcode_atts( array( 'comment_author_font_family' => 'regular', 'comment_date_font_family' => 'serif_regular', 'comment_content_font_family' => 'regular', 'comment_reply_font_family' => 'regular' ),$args['options']) ); // getcomment content ob_start(); comment_text(); $comment_content = ob_get_clean(); $comment_content = str_replace(array('<p>', '</p>'), array('<div>', '</div>'), $comment_content); ?> <div class="comment thread-even depth-<?php echo $depth; ?>" id="comment-<?php comment_ID(); ?>"> <div class="comment-author vcard" data-font="<?php echo $comment_author_font_family; ?>"> <?php echo get_avatar($comment, $args['avatar_size']); ?> <cite class="fn"> <?php echo get_comment_author_link($comment); ?> </cite> </div> <div class="comment-meta commentmetadata"> <a href="<?php echo esc_url(get_comment_link($comment, $args)); ?>" data-font="<?php echo $comment_date_font_family; ?>"> <?php echo get_comment_date( '', $comment ) . __(' at ', 'semplice') . get_comment_time(); ?> </a> </div> <?php if('0' == $comment->comment_approved ) : ?> <div class="comment-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></div> <?php endif; ?> <div class="comment-content" data-font="<?php echo $comment_content_font_family; ?>"><?php echo $comment_content; ?></div> <?php comment_reply_link(array_merge($args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '<div class="reply" data-font="' . $comment_reply_font_family . '">', 'after' => '</div>' ))); ?> <?php } // ----------------------------------------- // get blog comments // ----------------------------------------- public function get_comments($mode, $comments, $options) { // comments args $list_comments_args = array( 'avatar_size' => 48, 'style' => 'div', 'short_ping' => true, 'reply_text' => __('Reply', 'semplice'), 'max_depth' => 3, 'per_page' => -1, 'callback' => array($this, 'comments_html'), 'options' => $options, ); // width for default blog $width = 8; if(isset($options['blog_width'])) { $width = $options['blog_width']; } // title font $title_font = 'regular'; if(isset($options['comment_title_font_family'])) { $title_font = $options['comment_title_font_family']; } // title visibility $title_visibility = 'visible'; if(isset($options['comment_title_visibility'])) { $title_visibility = $options['comment_title_visibility']; } // comments open $output = ' <section id="comments" class="comments-area"> <div class="container"> <div class="row"> <div class="column" data-xl-width="' . $width . '" data-md-width="11" data-sm-width="12" data-xs-width="12"> '; // header and comment list $comments_html = '<div class="comments-title ' . $title_visibility . '" data-font="' . $title_font . '">' . __('Comments', 'semplice') . '</div>'; // has commentsß if($comments) { // comments open $comments_html .= '<div class="comments">'; // ob start ob_start(); // get comments wp_list_comments($list_comments_args, $comments); // change p to div $comments_html .= ob_get_clean(); // close comments list $comments_html .= '</div>'; } else { $comments_html .= '<p class="no-comments">' . __('No Comments.', 'semplice') . '</p>'; } // comments closed if(!comments_open() && get_comments_number() && post_type_supports(get_post_type(),'comments')) { $comments_html .= '<p class="no-comments">' . __('Comments are closed.', 'semplice') . '</p>'; } // comments form $commenter = wp_get_current_commenter(); $comments_html .= $this->form($options, array( 'name' => $commenter['comment_author'], 'email' => $commenter['comment_author_email'], 'url' => $commenter['comment_author_url'], )); // mode if($mode == 'default') { $output .= $comments_html; // close comments $output .= '</div></div></div></section>'; } else { $output = $comments_html; } // return return $output; } // ----------------------------------------- // get blog comments form // ----------------------------------------- public function form($options, $author) { // get options extract( shortcode_atts( array( 'comment_form_font_family' => 'regular', 'comment_submit_font_family' => 'regular', 'comment_reply_font_family' => 'regular', 'comment_respond_font_family' => 'regular', 'comment_submit_font_family' => 'regular' ),$options) ); // comment args $comment_form_args = array( 'id_form' => 'commentform', 'id_submit' => 'submit', 'title_reply' => '<span class="leave-reply-span">' . __('Leave a reply', 'semplice') . '</span><span class="reply-to-span" data-base="' . __('Reply to', 'semplice') . '">' . __('Reply to', 'semplice') . '</span>', 'title_reply_before' => '<h3 id="reply-title" class="comment-reply-title" data-font="' . $comment_respond_font_family . '">', 'cancel_reply_before' => '<span data-font="' . $comment_reply_font_family . '">', 'cancel_reply_after' => '</span>', 'cancel_reply_link' => __('Cancel reply', 'semplice'), 'label_submit' => __('Post Comment', 'semplice'), 'logged_in_as' => '', 'comment_field' => '<div class="comment-input"><textarea id="comment-input" class="mb10" data-font="' . $comment_form_font_family . '" name="comment" cols="45" rows="8" placeholder="' . __('Your comment*', 'semplice') . '" required email></textarea></div>', 'comment_notes_before' => '', 'comment_notes_after' => '', 'class_submit' => $comment_submit_font_family, 'fields' => apply_filters( 'comment_form_default_fields', array( 'author' => '<div class="comment-input"><input id="author" class="input" data-font="' . $comment_form_font_family . '" name="author" type="text" value="' . esc_attr($author['name']) . '" size="30" placeholder="' . __( 'Author*', 'semplice' ) . '" required /></div>', 'email' => '<div class="comment-input"><input id="email" class="input" data-font="' . $comment_form_font_family . '" name="email" type="email" value="' . esc_attr($author['email']) . '" size="30" placeholder="' . __( 'E-Mail Address*', 'semplice' ) . '" required /></div>', 'url' => '<div class="comment-input"><input id="url" class="input" data-font="' . $comment_form_font_family . '" name="url" type="text" value="' . esc_attr($author['url']) . '" size="30" placeholder="' . __( 'Website', 'semplice' ) . '" /></div>' )) ); // start output ob_start(); // echo form comment_form($comment_form_args); // get contents $output = ob_get_clean(); // return return $output; } // ----------------------------------------- // blog comments for customize // ----------------------------------------- public function customize_html($options) { // get options extract( shortcode_atts( array( 'comment_title_visibility' => 'visible', 'comment_title_font_family' => 'regular', 'comment_author_font_family' => 'regular', 'comment_date_font_family' => 'serif_regular', 'comment_content_font_family' => 'regular', 'comment_respond_font_family' => 'regular', 'comment_reply_font_family' => 'regular', 'comment_form_font_family' => 'regular', 'comment_submit_font_family' => 'regular' ),$options) ); return ' <div class="comments-title ' . $comment_title_visibility . '" data-font="' . $comment_title_font_family . '">Comments</div> <div class="comments"> <div class="comment odd alt thread-odd thread-alt depth-1 parent" id="comment-14"> <div class="comment-author vcard" data-font="' . $comment_author_font_family . '"> <img alt="" src="' . SEMPLICE_URI . '/assets/images/editor/blog/johnnyboy.png" class="avatar avatar-48 photo" height="48" width="48"> <cite class="fn"> <a href="http://homenick.org" rel="external nofollow" class="url">Johnnyboy</a> </cite> </div> <div class="comment-meta commentmetadata"> <a data-font="' . $comment_date_font_family . '">May 23, 2017 at 8:12 pm</a> </div> <div class="comment-content" data-font="' . $comment_content_font_family . '">Nulla est itaque velit sint sit. Cumque eos cum sit soluta sint. Laudantium et doloribus reiciendis distinctio sed repudiandae. Ad quasi qui eum optio.</div> <div class="reply" data-font="' . $comment_reply_font_family . '"> <a rel="nofollow" class="comment-reply-link" aria-label="Reply to Brandyn Flatley">Reply</a> </div> <div class="comment byuser comment-author-michael bypostauthor even depth-2" id="comment-41"> <div class="comment-author vcard" data-font="' . $comment_author_font_family . '"> <img alt="" src="' . SEMPLICE_URI . '/assets/images/editor/blog/vanessa.png" class="avatar avatar-48 photo" height="48" width="48"> <cite class="fn">Vanessa</cite> </div> <div class="comment-meta commentmetadata"> <a data-font="' . $comment_date_font_family . '">May 24, 2017 at 2:05 pm</a> </div> <div class="comment-content" data-font="' . $comment_content_font_family . '">Nulla est itaque velit sint sit. Cumque eos cum sit soluta sint. Laudantium et doloribus reiciendis distinctio sed repudiandae. Ad quasi qui eum optio.</div> <div class="reply" data-font="' . $comment_reply_font_family . '"> <a rel="nofollow" class="comment-reply-link" aria-label="Reply to Michael">Reply</a> </div> </div><!-- #comment-## --> </div><!-- #comment-## --> <div class="comment odd alt thread-even depth-1" id="comment-15"> <div class="comment-author vcard" data-font="' . $comment_author_font_family . '"> <img alt="" src="' . SEMPLICE_URI . '/assets/images/editor/blog/frucade.png" class="avatar avatar-48 photo" height="48" width="48"> <cite class="fn"> <a rel="external nofollow" class="url">Frucade</a> </cite> </div> <div class="comment-meta commentmetadata"> <a data-font="' . $comment_date_font_family . '">May 23, 2017 at 8:12 pm</a> </div> <div class="comment-content" data-font="' . $comment_content_font_family . '">Voluptatem non quae a. Minima tempora totam quaerat enim. Voluptatum sint fugiat consequatur nemo quos animi.</div> <div class="reply" data-font="' . $comment_reply_font_family . '"> <a rel="nofollow" class="comment-reply-link" aria-label="Reply to Olin Schmidt">Reply</a> </div> </div><!-- #comment-## --> </div> <div id="respond" class="comment-respond"> <h3 id="reply-title" class="comment-reply-title" data-font="' . $comment_respond_font_family . '">Reply to <small></small> Vanessa<a rel="nofollow" class="click-handler" data-handler="run" data-action-type="helper" data-setting-type="blog" data-action="removeCommentReplyLink" id="cancel-comment-reply-link" data-font="' . $comment_reply_font_family . '">Cancel Reply</a> </h3> <form method="post" id="commentform" class="comment-form"> <div class="comment-input"> <textarea id="comment-input" class="mb10" data-font="' . $comment_form_font_family . '" name="comment" cols="45" rows="8" placeholder="Your comment*" required="" email="">Dear Vanessa, i hope this comment will reach you in good health. I just stumbled upon your website and i have to say its ...</textarea> </div> <p class="form-submit"> <input name="submit" type="submit" id="submit" class="submit" value="Post Comment" data-font="' . $comment_submit_font_family . '"> <input type="hidden" name="comment_post_ID" value="1" id="comment_post_ID"> <input type="hidden" name="comment_parent" id="comment_parent" value="37"> </p> </form> </div> '; } } // instance Editor::$modules['blogcomments'] = new BlogcommentsModule; ?>
💾 保存文件
← 返回文件管理器