Skip to content

Commit

Permalink
Moved to template-parts from html in functions
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Nov 5, 2016
1 parent d966261 commit 7cf09da
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 76 deletions.
16 changes: 1 addition & 15 deletions app/setup/password-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,7 @@ public function __construct() {
*/
public function password_form( $output ) {
ob_start();
?>
<form action="<?php echo esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ); ?>" class="post-password-form" method="post">
<p>
<?php esc_html_e( 'This content is password protected. To view it please enter your password below:', 'mimizuku' ); ?>
</p>
<div class="_c-input-group">
<div class="_c-input-group__addon">
<?php esc_html_e( 'Password:', 'mimizuku' ); ?>
</div>
<div class="_c-input-group__field">
<input class="_c-input-group__control" name="post_password" type="password" size="20" />
</div><input class="_c-input-group__btn" type="submit" name="Submit" value="<?php echo esc_attr_x( 'Enter', 'post password form', 'mimizuku' ); ?>" />
</div>
</form>
<?php
get_template_part( 'template-parts/password-form' );
$output = ob_get_clean();
$output = str_replace( [ "\n", "\r", "\n\r", "\t" ], '', $output );
return $output;
Expand Down
2 changes: 1 addition & 1 deletion app/tags/get-template-part.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @return void
*/
function get_template_part( $template, $vars = [] ) {
$template_part = new \Mimizuku\Template_Part( $template );
$template_part = new \Mimizuku\App\Models\Template_Part( $template );
$template_part->set_vars( $vars );
$template_part->render();
}
48 changes: 7 additions & 41 deletions app/tags/the-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,12 @@
function the_comments( $comment, $args, $depth ) {
?>
<li <?php comment_class( [ '_p-comments__item' ] ); ?> id="li-comment-<?php comment_ID() ?>">
<div class="_p-comment" id="comment-<?php comment_ID(); ?>">
<div class="_p-comment__figure">
<?php echo get_avatar( $comment, '48' ); ?>
</div>
<div class="_p-comment__body">
<?php if ( 0 === $comment->comment_approved ) : ?>
<em><?php esc_html_e( 'Your comment is awaiting moderation.', 'mimizuku' ) ?></em>
<?php endif; ?>
<div class="_p-comment__meta">
<?php
$author = sprintf( '<cite>%s</cite>', get_comment_author_link() );
$date = get_comment_date();
$time = get_comment_time();
printf(
esc_html__( '%1$s said on %2$s at %3$s', 'mimizuku' ),
wp_kses_post( $author ),
wp_kses_post( $date ),
wp_kses_post( $time )
);
edit_comment_link( 'edit', ' ', '' );
?>
</div>

<div class="_p-comment__content">
<?php comment_text() ?>
</div>

<?php
$args = array_merge( $args, [
'depth' => $depth,
'max_depth' => $args['max_depth'],
] );
?>

<?php if ( ! empty( get_comment_reply_link( $args ) ) ) : ?>
<div class="_p-comment__reply">
<?php comment_reply_link( $args ); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php
\Mimizuku\App\Tags\get_template_part( 'template-parts/comment', [
'_comment' => $comment,
'_args' => $args,
'_depth' => $depth,
] );
?>
<?php
}
20 changes: 1 addition & 19 deletions app/tags/the-pings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@
function the_pings() {
?>
<li <?php comment_class( [ '_c-trackbacks__item' ] ); ?> id="li-comment-<?php comment_ID() ?>">
<dl class="_p-trackback" id="comment-<?php comment_ID(); ?>">
<dt class="_p-trackback__meta">
<?php
$author = sprintf( '<cite>%s</cite>', get_comment_author_link() );
$date = get_comment_date();
$time = get_comment_time();
printf(
esc_html__( '%1$s said on %2$s at %3$s', 'mimizuku' ),
wp_kses_post( $author ),
wp_kses_post( $date ),
wp_kses_post( $time )
);
edit_comment_link( 'edit', ' ', '' );
?>
</dt>
<dd class="_p-trackback__body">
<?php comment_text() ?>
</dd>
</dl>
<?php \Mimizuku\App\Tags\get_template_part( 'template-parts/trackback' ); ?>
<?php
}
48 changes: 48 additions & 0 deletions template-parts/comment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* @package mimizuku
* @author inc2734
* @license GPL-2.0+
*/
?>
<div class="_p-comment" id="comment-<?php comment_ID(); ?>">
<div class="_p-comment__figure">
<?php echo get_avatar( $_comment, '48' ); ?>
</div>
<div class="_p-comment__body">
<?php if ( 0 === $_comment->comment_approved ) : ?>
<em><?php esc_html_e( 'Your comment is awaiting moderation.', 'mimizuku' ) ?></em>
<?php endif; ?>
<div class="_p-comment__meta">
<?php
$author = sprintf( '<cite>%s</cite>', get_comment_author_link() );
$date = get_comment_date();
$time = get_comment_time();
printf(
esc_html__( '%1$s said on %2$s at %3$s', 'mimizuku' ),
wp_kses_post( $author ),
wp_kses_post( $date ),
wp_kses_post( $time )
);
edit_comment_link( 'edit', ' ', '' );
?>
</div>

<div class="_p-comment__content">
<?php comment_text() ?>
</div>

<?php
$args = array_merge( $_args, [
'depth' => $_depth,
'max_depth' => $_args['max_depth'],
] );
?>

<?php if ( ! empty( get_comment_reply_link( $args ) ) ) : ?>
<div class="_p-comment__reply">
<?php comment_reply_link( $args ); ?>
</div>
<?php endif; ?>
</div>
</div>
20 changes: 20 additions & 0 deletions template-parts/password-form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* @package mimizuku
* @author inc2734
* @license GPL-2.0+
*/
?>
<form action="<?php echo esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ); ?>" class="post-password-form" method="post">
<p>
<?php esc_html_e( 'This content is password protected. To view it please enter your password below:', 'mimizuku' ); ?>
</p>
<div class="_c-input-group">
<div class="_c-input-group__addon">
<?php esc_html_e( 'Password:', 'mimizuku' ); ?>
</div>
<div class="_c-input-group__field">
<input class="_c-input-group__control" name="post_password" type="password" size="20" />
</div><input class="_c-input-group__btn" type="submit" name="Submit" value="<?php echo esc_attr_x( 'Enter', 'post password form', 'mimizuku' ); ?>" />
</div>
</form>
26 changes: 26 additions & 0 deletions template-parts/trackback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @package mimizuku
* @author inc2734
* @license GPL-2.0+
*/
?>
<dl class="_p-trackback" id="comment-<?php comment_ID(); ?>">
<dt class="_p-trackback__meta">
<?php
$author = sprintf( '<cite>%s</cite>', get_comment_author_link() );
$date = get_comment_date();
$time = get_comment_time();
printf(
esc_html__( '%1$s said on %2$s at %3$s', 'mimizuku' ),
wp_kses_post( $author ),
wp_kses_post( $date ),
wp_kses_post( $time )
);
edit_comment_link( 'edit', ' ', '' );
?>
</dt>
<dd class="_p-trackback__body">
<?php comment_text() ?>
</dd>
</dl>

0 comments on commit 7cf09da

Please sign in to comment.