Skip to content

Commit

Permalink
Merge pull request #658 from vektor-inc/develop
Browse files Browse the repository at this point in the history
14.3.2
  • Loading branch information
kurudrive authored May 29, 2021
2 parents 1592d22 + f1b216c commit d4bc2ca
Show file tree
Hide file tree
Showing 26 changed files with 132 additions and 78 deletions.
2 changes: 1 addition & 1 deletion _g2/assets/css/common.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _g2/assets/css/common_editor.css

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions _g2/inc/vk-components/package/_scss/_vk-post-type-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,14 @@ https://github.com/vektor-inc/vektor-wp-libraries
/*-------------------------------------------*/
/* .card-noborder
/*-------------------------------------------*/
:root {
--vk-color-border-hr: #e5e5e5;
}
.card-noborder {
&.card {
/*.card.card-noborder にしないと負ける */
border: none;
background: none;
}
.vk_post_imgOuter {
border : 1px solid var(--vk-color-border-hr);
border : 1px solid var(--vk-color-border-image);
}
.card-body {
padding-left: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ https://github.com/vektor-inc/vektor-wp-libraries
/*-------------------------------------------*/
.media {
&-img {
border: $border_primary;
border: $border_image;
padding: 1px;
margin-right: 1rem;
}
Expand Down
29 changes: 20 additions & 9 deletions _g2/inc/vk-components/package/_scss/_vk-post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ https://github.com/vektor-inc/vektor-wp-libraries

/* Bootstrap Adjuster */
$border_primary: 1px solid var(--vk-color-border-hr,#e5e5e5 );
$border_image: 1px solid var(--vk-color-border-image);
$color_font_default: #464646;
$margin_post_item_element: 0.8rem;
$margin_post_item_element_narrow: 0.4rem;

:root {
--vk-size-text-xs:11px;
--vk-font-size-xs:11px;
--vk-color-link-text: #c00;
--vk-color-link-text-hover: #c00;
--vk-color-text-body: #333;
--vk-color-text-light: #666;
--vk-color-border-hr: #e5e5e5;
--vk-color-border-image: #e5e5e5;
--vk-line-height-low: 1.5em;
}

Expand Down Expand Up @@ -198,24 +200,30 @@ $xxl-min: 1400px;
opacity: 0.8;
}
& &_date {
font-size: var(--vk-size-text-xs);
font-size: var(--vk-font-size-xs);
margin-top: $margin_post_item_element_narrow;
color: var(--vk-color-text-light);
}
&_author {
margin: $margin_post_item_element 0;
&_image,
&_name {
display: inline-block;
vertical-align: middle;
}
&_image {
margin-right:10px;
margin-right:0.5rem;
img{
width:24px;
height:24px;
object-fit:cover;
border-radius:50%;
object-position:0px 0px;
display: block;
}
}
&_name{
font-size:var(--vk-size-text-xs);
font-size:var(--vk-font-size-xs);
}
}
&_taxonomies {
Expand All @@ -225,7 +233,7 @@ $xxl-min: 1400px;
display: flex;
flex-direction: row;
margin: 0;
font-size: var(--vk-size-text-xs);
font-size: var(--vk-font-size-xs);
&:first-child {
margin-top:0;
}
Expand Down Expand Up @@ -258,7 +266,10 @@ $xxl-min: 1400px;
& &_btn {
font-size: 12px;
text-decoration: none;

// カードの幅が狭い時にボタンが改行されてボタンの上のテキストと重なるため、通常のボタンより左右の余白を狭く変更
padding-left:1rem;
padding-right:1rem;
white-space: nowrap;
}
}

Expand All @@ -270,7 +281,7 @@ $xxl-min: 1400px;
position: relative;
background-size: cover;
background-position: center 50%;
border-bottom: $border_primary;
border-bottom: $border_image;
& > a::after {
content: "";
position: absolute;
Expand Down Expand Up @@ -305,15 +316,15 @@ $xxl-min: 1400px;
.vk_post_imgOuter {
height: 100%;
border-bottom: none;
border-right:$border_primary;
border-right:$border_image;
&:before {
padding-top: 0;
}
}
&.card-horizontal-reverse {
.vk_post_imgOuter {
border-right:none;
border-left:$border_primary;
border-left:$border_image;
}
}
}
Expand Down
50 changes: 29 additions & 21 deletions _g2/inc/vk-components/package/class-vk-component-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ public static function get_loop( $wp_query, $options, $options_loop = array() )

endif;

/*
wp_reset_query() がないとトップページでショートコードなどから呼び出した場合に
固定ページのトップ指定が解除されて投稿一覧が表示される
→ と言いたい所だが、そもそも global $wp_query を上書きするなという話で、
wp_reset_query()をするという事は余分に1回クエリが走る事になるので、
$wp_query を上書きしないルールにしてここでは wp_reset_query() を走らせない
*/
// wp_reset_query();
wp_reset_postdata();
return $loop;
}
Expand Down Expand Up @@ -238,7 +246,7 @@ public static function get_thumbnail_image( $post, $options, $attr = array() ) {

$html .= '<div class="vk_post_imgOuter' . $classes['class_outer'] . '"' . $style . '>';

if ( $options['layout'] != 'card-intext' ){
if ( $options['layout'] != 'card-intext' ) {
$html .= '<a href="' . get_the_permalink( $post->ID ) . '">';
}

Expand Down Expand Up @@ -274,7 +282,7 @@ public static function get_thumbnail_image( $post, $options, $attr = array() ) {
$html .= '<img src="' . esc_url( $options['image_default_url'] ) . '" alt="" class="' . $image_class . '" loading="lazy" />';
}

if ( $options['layout'] != 'card-intext' ){
if ( $options['layout'] != 'card-intext' ) {
$html .= '</a>';
}

Expand Down Expand Up @@ -314,7 +322,7 @@ public static function get_view_body( $post, $options ) {
カードインテキストの場合、リンクの中にリンクがあるとブラウザでDOMが書き換えられるので
中のリンクを解除する必要がある。
*/
if ( $options['layout'] == 'card-intext' ){
if ( $options['layout'] == 'card-intext' ) {
$options['textlink'] = false;
}

Expand Down Expand Up @@ -358,10 +366,11 @@ public static function get_view_body( $post, $options ) {

// VK Post Author Display の画像を取得
$profile_image_id = get_the_author_meta( 'user_profile_image' );
$html .= '<span class="vk_post_author_image">';
$html .= '<span class="vk_post_author_image">';
if ( $profile_image_id ) {
$profile_image_src = wp_get_attachment_image_src( $profile_image_id, 'thumbnail' );
$html .= '<img class="vk_post_author_image" src="' . $profile_image_src[0] . '" alt="' . esc_attr( $author ) . '" />';
// Gravater の時はクラス名つけられないので、こちらにもつけないこと。
$html .= '<img src="' . $profile_image_src[0] . '" alt="' . esc_attr( $author ) . '" />';
} else {
$html .= get_avatar( get_the_author_meta( 'email' ), 100 );
}
Expand All @@ -374,18 +383,18 @@ public static function get_view_body( $post, $options ) {
}

if ( $options['display_taxonomies'] ) {
$args = array(
$args = array(
'template' => '<dt class="vk_post_taxonomy_title"><span class="vk_post_taxonomy_title_inner">%s</span></dt><dd class="vk_post_taxonomy_terms">%l</dd>',
'term_template' => '<a href="%1$s">%2$s</a>',
);
$taxonomies = get_the_taxonomies( $post->ID, $args );
$exclusion = array( 'product_type' );
$taxonomies = get_the_taxonomies( $post->ID, $args );
$exclusion = array( 'product_type' );
// このフィルター名は投稿詳細でも使っているので注意
$exclusion = apply_filters( 'vk_get_display_taxonomies_exclusion', $exclusion );
$exclusion = apply_filters( 'vk_get_display_taxonomies_exclusion', $exclusion );

if ( is_array( $exclusion ) ){
foreach ( $exclusion as $key => $value ){
unset( $taxonomies[$value] );
if ( is_array( $exclusion ) ) {
foreach ( $exclusion as $key => $value ) {
unset( $taxonomies[ $value ] );
}
}
if ( $taxonomies ) {
Expand Down Expand Up @@ -422,7 +431,6 @@ public static function get_view_body( $post, $options ) {
$html .= VK_Component_Button::get_view( $button_options );
$html .= '</div>';
}

}

if ( ! empty( $options['body_append'] ) ) {
Expand All @@ -446,7 +454,7 @@ public static function get_patterns() {
'label' => __( 'Card', 'lightning' ),
'class_posts_outer' => '',
),
'card-noborder' => array(
'card-noborder' => array(
'label' => __( 'Card Noborder', 'lightning' ),
'class_posts_outer' => '',
),
Expand Down Expand Up @@ -480,18 +488,18 @@ public static function get_view_type_card( $post, $options ) {
'class_image' => 'card-img-top',
);

$html_body = '';
$html_body = '';
$html_body .= self::get_thumbnail_image( $post, $options, $attr );
$html_body .= self::get_view_body( $post, $options );

if ( $options['layout'] == 'card-intext' ){
if ( $options['layout'] == 'card-intext' ) {

$html .= '<a href="' . esc_url( get_the_permalink( $post->ID ) ) . '" class="card-intext-inner">';

// aタグ内にaタグがあるとChromeなどはその時点で一旦aタグを閉じてしまって表示が崩れるので、aタグをspanに変換する
$html_body = str_replace( "<a", "<span", $html_body );
$html_body = str_replace( "href=", "data-url=", $html_body );
$html_body = str_replace( "a>", "span>", $html_body );
$html_body = str_replace( '<a', '<span', $html_body );
$html_body = str_replace( 'href=', 'data-url=', $html_body );
$html_body = str_replace( 'a>', 'span>', $html_body );

$html .= $html_body;

Expand Down Expand Up @@ -638,8 +646,8 @@ public static function get_col_converted_size( $input_col = 4 ) {
} elseif ( $input_col == 6 ) {
$col = 2;
} else {
$col = 4;
}
$col = 4;
}
return strval( $col );
}

Expand Down
Loading

0 comments on commit d4bc2ca

Please sign in to comment.