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 / 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' );
@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 / 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 / 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 / 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 / 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',