Skip to content

Commit

Permalink
ACF Block でカメラジ・スライダーを作成
Browse files Browse the repository at this point in the history
  • Loading branch information
toiee-kameda committed Dec 1, 2020
1 parent a99c966 commit 5841727
Show file tree
Hide file tree
Showing 4 changed files with 485 additions and 1 deletion.
2 changes: 2 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ function enqueue_our_required_stylesheets() {

require_once 'includes/trial.php';

require_once 'includes/block-slider.php';

/**
* シリーズ名を表示するためのテンプレートタグ
*
Expand Down
322 changes: 322 additions & 0 deletions includes/block-slider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
<?php
/**
* ブロックの記述をします
*
* @package block
*/

add_action('acf/init', 'kameradio_slider_acf_init_block_types');
/**
* カメラジ・スライダーブロックを登録します
*
* @return void
*/
function kameradio_slider_acf_init_block_types() {
if ( function_exists( 'acf_register_block_type' ) ) {

// register a testimonial block.
acf_register_block_type(
array(
'name' => 'kameradio_slider',
'title' => __('カメラジスライダー'),
'description' => __('ウェビナー、シリーズ、エピソード、ブログ、ページなどへのスライダーを作ります'),
'render_template' => 'template-parts/blocks/kameradio-slider/kameradio-slider.php',
'category' => 'formatting',
'icon' => 'admin-comments',
'keywords' => array('slider', 'kame', 'kameradi', 'kameradio'),
)
);
}
}

add_action(
'wp_enqueue_scripts',
function () {
wp_enqueue_script( 'slick', get_theme_file_uri( '/js/slick.js' ), array( 'jquery' ), '1.9.0', true );
wp_enqueue_style( 'slick-style', get_theme_file_uri( '/css/slick.css' ), array(), '1.9.0' );
}
);

add_action(
'enqueue_block_assets',
function() {
wp_enqueue_style(
'slick-style',
get_theme_file_uri( '/css/slick.css' ),
array(),
'1.9.0'
);
}
);

add_action(
'enqueue_block_editor_assets',
function() {
wp_enqueue_script(
'slick',
get_theme_file_uri( '/js/slick.js' ),
array( 'wp-blocks', 'wp-element', 'wp-hooks', 'jquery' ),
'1.9.0',
true
);
}
);

if ( function_exists( 'acf_add_local_field_group' ) ) :

acf_add_local_field_group( array(
'key' => 'group_5fc5978be30ee',
'title' => 'スライダー要素',
'fields' => array(
array(
'key' => 'field_5fc59799aa8cd',
'label' => 'スライダー要素',
'name' => 'slider_elements',
'type' => 'flexible_content',
'instructions' => 'スライダーに使う様々な要素を指定してください。',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'layouts' => array(
'layout_5fc597afb281a' => array(
'key' => 'layout_5fc597afb281a',
'name' => 'latest_webinars',
'label' => '最新Webinar一覧',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_5fc597d9aa8ce',
'label' => 'num',
'name' => 'num',
'type' => 'number',
'instructions' => '表示するWebinarの数を指定',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => 5,
'placeholder' => 5,
'prepend' => '',
'append' => '',
'min' => '',
'max' => '',
'step' => '',
),
array(
'key' => 'field_5fc59a83aa8d6',
'label' => 'ボタンテキスト',
'name' => 'button_text',
'type' => 'text',
'instructions' => '表示するボタンテキストです(全て共通)。',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '参加する',
'placeholder' => '参加する',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'min' => '',
'max' => '',
),
'layout_5fc59821aa8cf' => array(
'key' => 'layout_5fc59821aa8cf',
'name' => 'series',
'label' => 'シリーズ',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_5fc59837aa8d0',
'label' => 'シリーズ',
'name' => 'series',
'type' => 'taxonomy',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'taxonomy' => 'series',
'field_type' => 'select',
'allow_null' => 0,
'add_term' => 0,
'save_terms' => 0,
'load_terms' => 0,
'return_format' => 'object',
'multiple' => 0,
),
array(
'key' => 'field_5fc5988eaa8d1',
'label' => 'リード',
'name' => 'lead',
'type' => 'text',
'instructions' => 'シリーズ名の下に表示するリード文章を指定できます',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5fc59ac5aa8d7',
'label' => 'ボタンテキスト',
'name' => 'button_text',
'type' => 'text',
'instructions' => '表示するボタンテキストです',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '詳細',
'placeholder' => '詳細',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'min' => '',
'max' => '',
),
'layout_5fc598c5aa8d2' => array(
'key' => 'layout_5fc598c5aa8d2',
'name' => 'post',
'label' => '投稿(ブログ、ページ、ウェビナー、エピソード)',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_5fc598d2aa8d3',
'label' => '投稿オブジェクト',
'name' => 'post_obj',
'type' => 'post_object',
'instructions' => '表示するエピソード単体を選ぶことができます',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'post_type' => array(
0 => 'podcast',
1 => 'webinar',
2 => 'post',
3 => 'page',
),
'taxonomy' => '',
'allow_null' => 0,
'multiple' => 0,
'return_format' => 'object',
'ui' => 1,
),
array(
'key' => 'field_5fc5999daa8d5',
'label' => 'タイトル',
'name' => 'title',
'type' => 'text',
'instructions' => 'スライダーに使うタイトルです。指定しなければ、投稿タイトルを使います。',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5fc5995caa8d4',
'label' => 'リード',
'name' => 'lead',
'type' => 'text',
'instructions' => 'スライダーに使うリード文章(タイトルの下)です。指定しなければ、抜粋を使います。',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5fc59b1daa8d8',
'label' => 'ボタンテキスト',
'name' => 'button_text',
'type' => 'text',
'instructions' => 'ボタンに表示するテキストです',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '今すぐ視聴する',
'placeholder' => '今すぐ視聴する',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'min' => '',
'max' => '',
),
),
'button_label' => '行を追加',
'min' => '',
'max' => '',
),
),
'location' => array(
array(
array(
'param' => 'block',
'operator' => '==',
'value' => 'acf/kameradio-slider',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));

endif;
15 changes: 14 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: Businesspress child theme.
Author: toiee Lab
Author URI: https://toiee.jp/
Template: businesspress
Version: 1.8
Version: 2.0
*/

.page-title-series {
Expand Down Expand Up @@ -121,4 +121,17 @@ Version: 1.8
.webinar-disable,
.webinar-disable a {
color : #aaa;
}

.featured-lead p {
color : rgba( 255, 255, 255, 0.8 );
font-size: 80%;
}

.featured-entry-date-slider {
color : white;
}

.featured-lead .home-header-button a {
margin-top: 10px;
}
Loading

0 comments on commit 5841727

Please sign in to comment.