Skip to content

Commit

Permalink
Merge branch 'master' into update/67-translate
Browse files Browse the repository at this point in the history
  • Loading branch information
kurudrive committed Nov 11, 2024
2 parents 0bb0b52 + fc98766 commit 1ffe7b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 63 deletions.
33 changes: 15 additions & 18 deletions inc/promotion-alert/package/class-veu-promotion-alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,6 @@ public static function get_alert_content() {
$alert = '';
$alert_content = '';

// 表示条件を判定
$display = self::is_display( get_the_ID() );

// 表示条件が true の場合はアラートを表示
if ( ! empty( $display ) ) {

// オプションを取得
$options = self::get_options();

Expand All @@ -452,7 +446,6 @@ public static function get_alert_content() {
$alert = wp_kses( '<div class="veu_promotion-alert">' . $alert_content . '</div>', $allowed_html );
$alert = str_replace( '<div class="veu_promotion-alert">', '<div class="veu_promotion-alert" data-nosnippet>', $alert );
}
}

// 許可されたHTMLタグで再度サニタイズ
return apply_filters( 'veu_promotion_alert_content', $alert );
Expand All @@ -465,11 +458,12 @@ public static function get_alert_content() {
*/
public static function display_alert_filter( $content ) {

// アラートを取得
$alert = self::get_alert_content();

// 文頭にアラートを追加
$content = $alert . $content;
if ( self::is_display( get_the_ID() ) ){
// アラートを取得
$alert = self::get_alert_content();
// 文頭にアラートを追加
$content = $alert . $content;
}

return $content;
}
Expand All @@ -479,12 +473,15 @@ public static function display_alert_filter( $content ) {
*/
public static function display_alert_action() {

// アラートを取得
$alert = self::get_alert_content();
// 許可されたHTMLタグ
$allowed_html = self::kses_allowed();

echo wp_kses( $alert, $allowed_html );
if ( self::is_display( get_the_ID() ) ){
// アラートを取得
$alert = self::get_alert_content();
// 許可されたHTMLタグ
$allowed_html = self::kses_allowed();
echo wp_kses( $alert, $allowed_html );
} else {
return;
}
}

/**
Expand Down
44 changes: 0 additions & 44 deletions tests/test-promotion-alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,50 +422,6 @@ public function test_get_alert_content() {
),
'correct' => '<div class="veu_promotion-alert" data-nosnippet><div class="veu_promotion-alert__content--custom">bbbb</div></div>',
),
array(
'name' => 'No text and content / display:hide',
'options' => array(
'alert-text' => '',
'alert-content' => '',
'alert-display' => array(
'post' => 'hide',
),
),
'correct' => '',
),
array(
'name' => 'No content / display:hide',
'options' => array(
'alert-text' => 'aaaa',
'alert-content' => '',
'alert-display' => array(
'post' => 'hide',
),
),
'correct' => '',
),
array(
'name' => 'No text / display:hide',
'options' => array(
'alert-text' => '',
'alert-content' => 'bbbb',
'alert-display' => array(
'post' => 'hide',
),
),
'correct' => '',
),
array(
'name' => 'Normal text and content / display:hide',
'options' => array(
'alert-text' => 'aaaa',
'alert-content' => 'bbbb',
'alert-display' => array(
'post' => 'hide',
),
),
'correct' => '',
),
// XSS属性の削除をテスト
array(
'name' => 'XSS content',
Expand Down
2 changes: 1 addition & 1 deletion vkExUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
Copyright 2015-2024 Vektor,Inc. ( email : [email protected] )
Copyright 2015-2024 Vektor,Inc. ( email : [email protected] )
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
Expand Down

0 comments on commit 1ffe7b0

Please sign in to comment.