Skip to content

Instantly share code, notes, and snippets.

View Olein-jp's full-sized avatar
🏠
Working from home

Koji Kuno Olein-jp

🏠
Working from home
View GitHub Profile
@Olein-jp
Olein-jp / block-bindings-custom-fields-test.php
Created April 29, 2024 06:58
ブロックバリエーションを作成してカスタムフィールドを出力するサンプル
function book_introduce_block_type_variations( $variations, $block_type ) {
if ( 'core/heading' === $block_type->name ) {
$variations[] = array(
'name' => 'book-title',
'title' => 'Book Title',
'attributes' => array(
'metadata' => array(
'bindings' => array(
'content' => array(
'source' => 'acf/field',
@Olein-jp
Olein-jp / script.js
Created March 4, 2022 03:30
タブを動かすスクリプト
document.addEventListener('DOMContentLoaded', function(){
// タブに対してクリックイベントを適用
const tabs = document.getElementsByClassName('tab-item');
for(let i = 0; i < tabs.length; i++) {
tabs[i].addEventListener('click', tabSwitch, false);
}
// タブをクリックすると実行する関数
function tabSwitch(){
// タブのclassの値を変更
@Olein-jp
Olein-jp / script.js
Created March 4, 2022 03:14
自ページへアンカーリンクを持つ要素の親要素に任意のクラス名を付与する
window.onload = function() {
const htmlFileName = window.location.href.split( '/' ).pop();
const fileSlugName = htmlFileName.split( '.' ).shift();
console.log(fileSlugName);
regex = new RegExp( fileSlugName );
const targetElement = document.getElementById( 'column-navigation-content' );
const linkElement = targetElement.getElementsByTagName( 'a' );
const linkElements = Array.from( linkElement );
@Olein-jp
Olein-jp / package.json
Created February 20, 2022 23:44
静的なサイトコーディングの際の環境例
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"message": "echo changed",
"compile:css:sass": "sass src/sass:dest/css --style=expanded --no-source-map",
"compile:css:postcss": "postcss dest/css/*.css -r",
"compile:css": "run-s compile:css:sass compile:css:postcss",
@Olein-jp
Olein-jp / deploy.yml
Last active November 4, 2021 00:59
YAML for file uploading via FTP when you pushed master branch with new tag
name: Deploy via Github Actions to Production
on:
push:
branches:
- main
tags:
- '[0-9]+.[0-9]+.[0-9]*'
jobs:
test:
@Olein-jp
Olein-jp / my-snow-monkey.php
Created June 25, 2021 23:22
Output Advanced Custom Fields on Snow Monkey
/**
* カスタム投稿タイプのアーカイブページにAFC情報を掲載する
*/
add_filter(
'snow_monkey_template_part_render_template-parts/loop/entry-summary/content/content',
function( $html ) {
if ( is_post_type_archive( 'custom_post_type' ) ) {
$match_date = get_field( 'match_date' );
$match_score = get_field( 'match_score' );
$match_result = get_field( 'match_result' );
/**
* 編集画面でカスタムタクソノミーを一覧表示(チェックボックス)させる
*/
add_action(
'init',
function() {
$tag_slug_args = get_taxonomy('jobs_skill');
$tag_slug_args->hierarchical = true;
$tag_slug_args->meta_box_cb = 'post_categories_meta_box';
register_taxonomy('jobs_skill', 'jobs', (array) $tag_slug_args);
@Olein-jp
Olein-jp / add-editor-style-for-my-snow-monkey.php
Last active March 26, 2021 04:58
My Snow Monkey にエディタースタイル用CSSファイルを読み込み
<?php
/**
* Editor style
*/
function oleindesign_editor_style_register()
{
wp_enqueue_style('oleindesign-editor-style', plugins_url('editor-style.css', __FILE__));
}
add_action('enqueue_block_editor_assets', 'oleindesign_editor_style_register');
@Olein-jp
Olein-jp / add-style-for-my-snow-monkey.php
Last active March 26, 2021 04:56
My Snow Monkey にオリジナルCSSスタイルファイルを読み込み
<?php
/**
* オリジナルCSS読み込み
*/
function od_enqueue_scripts()
{
wp_enqueue_style('od_styles', plugins_url('style.css', __FILE__));
}
add_action('wp_enqueue_scripts', 'od_enqueue_scripts');
/* 見出し全体
------------------------------*/
h2,
h3,
h4,
h5,
h6 {
}