get_block_core_post_featured_image_border_attributes()


WordPressのget_block_core_post_featured_image_border_attributes()関数は、ブロックエディタで使用される投稿のアイキャッチ画像に適用されるボーダー属性を取得するために使用されます。この関数は、Gutenbergブロックエディタのコアブロック「Post Featured Image」で使用されるスタイル属性を生成します。

構文

get_block_core_post_featured_image_border_attributes( array $border );

引数の説明:

  • $border (array) — ボーダーのスタイルを定義する配列。キーとしてcolorstylewidthなどを含むことができます。

例1: 基本的なボーダー属性の取得

この例では、シンプルなボーダー属性を取得します。

$border = array('color' => '#000000', 'style' => 'solid', 'width' => '2px'); echo get_block_core_post_featured_image_border_attributes($border);

例2: カスタムカラーのボーダー

カスタムカラーを使用してボーダー属性を取得します。

$border = array('color' => '#ff0000', 'style' => 'dashed'); echo get_block_core_post_featured_image_border_attributes($border);

例3: ボーダーの幅を指定

ボーダーの幅を指定して属性を取得します。

$border = array('width' => '5px', 'style' => 'solid'); echo get_block_core_post_featured_image_border_attributes($border);

例4: 複数のボーダー属性を組み合わせる

複数のボーダー属性を組み合わせて使用します。

$border = array('color' => '#00ff00', 'style' => 'double', 'width' => '3px'); echo get_block_core_post_featured_image_border_attributes($border);

例5: ボーダースタイルのみ指定

ボーダースタイルのみを指定して属性を取得します。

$border = array('style' => 'dotted'); echo get_block_core_post_featured_image_border_attributes($border);

例6: カスタムクラスを追加

ボーダー属性にカスタムクラスを追加します。

$border = array('color' => '#0000ff', 'class' => 'custom-border'); echo get_block_core_post_featured_image_border_attributes($border);

例7: ボーダーなしの場合

ボーダーが指定されていない場合のデフォルトの動作です。

$border = array(); echo get_block_core_post_featured_image_border_attributes($border);

注意点

  • ボーダーのスタイルが無効な場合、デフォルトのスタイルが適用されることがあります。
  • 配列のキーが正しく指定されていない場合、関数は期待通りの結果を返さない可能性があります。

関連機能: