Skip to content

Instantly share code, notes, and snippets.

View inc2734's full-sized avatar

Takashi Kitajima inc2734

View GitHub Profile
@fumikito
fumikito / wp-env-restore.sh
Created April 12, 2023 06:31
Fix wp-env container
#! /usr/bin/env bash
# see https://otti.xyz/2021/05/how-to-fix-wp-env-mysqlcheck-error.html
LINE=$( docker ps | grep tests-wordpress- )
HERE=$(pwd)
LINE=${LINE##* }
LINE=${LINE%%-*}
echo "Restore container: $LINE"
@torounit
torounit / useMeta.js
Last active September 1, 2020 03:28
useState 風味に WordPressのカスタムフィールドを扱うやつ
import { Fragment, useCallback } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
const useMeta = ( key ) => {
const meta = useSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );
const values = getEditedPostAttribute( 'meta' ) || {};
return values[ key ] || '';
}, [] );

Custom Gutenberg Block

This is a basic custom Gutenberg block. Files explained below.

  • block.js — We register Custom Gutenberg block here.
  • editor.css _ Block CSS for the editor.
  • style.css — Block CSS for the front end.
  • index.php — Enqueue block's assets for editor and the front end.
@marushu
marushu / package.json
Last active July 8, 2017 05:33
Task runner for building WordPress theme
{
"name": "task-runner-for-wordpress-theme",
"version": "1.1.0",
"description": "new task runner for hibou build themes :)",
"scripts": {
"lint": "eslint ./js || true",
"scss": "node-sass --output-style expanded --indent-type tab --indent-width 2 -o ./ ./sass/style.scss",
"autoprefixer": "postcss -u autoprefixer --autoprefixer.browsers '> 5%, ie 9' -r ./style.css",
"imagemin": "imagemin ../../../../dist/* -o ./common/img",
"icons": "svgo -f ./common/img && mkdir -p ./common/img && svg-sprite-generate -d ../../../../dist/ -o ./common/img/icons.svg",
@kevinwhoffman
kevinwhoffman / add-styles-to-visual-editor.php
Last active January 30, 2022 14:15
Add customizer styles to visual editor
<?php
/**
* Adds styles from customizer to head of TinyMCE iframe.
* These styles are added before all other TinyMCE stylesheets.
* h/t Otto.
*/
function kwh_add_editor_style( $mceInit ) {
// This example works with Twenty Sixteen.
$background_color = get_theme_mod( 'background_color' );
$styles = '.mce-content-body { background-color: #' . $background_color . '; }';
@zenith6
zenith6 / mw-wp-form-memory.patch
Created April 21, 2016 05:51
MW WP Form メモリ使用量軽減パッチ
diff --git a/src/wp-content/plugins/mw-wp-form/classes/controllers/class.chart.php b/src/wp-content/plugins/mw-wp-form/classes/controllers/class.chart.php
index 65dd853..72e091d 100644
--- a/src/wp-content/plugins/mw-wp-form/classes/controllers/class.chart.php
+++ b/src/wp-content/plugins/mw-wp-form/classes/controllers/class.chart.php
@@ -91,6 +91,27 @@ class MW_WP_Form_Chart_Controller extends MW_WP_Form_Controller {
}
/**
+ * データ件数を取得
+ *
@miya0001
miya0001 / hook-test.php
Last active February 6, 2016 11:06
一回だけだよっ!ていうサンプル
<?php
add_action( 'shutdown', 'my_shutdown_callback' );
function my_shutdown_callback() {
do_action( 'custom_shutdown_hook' );
}
add_action( 'save_post', 'my_save_post_callback' );
@torounit
torounit / Admin_Column_Custom_Field.php
Last active February 29, 2016 14:39
WordPressの投稿一覧にカスタムフィールドを表示する。並び替えにも対応。
<?php
Class Admin_Column_Custom_Field {
/** @var string */
private $field_key;
/** @var string */
private $field_label;
@megane9988
megane9988 / gist:7982091
Last active December 31, 2015 11:49
gruntことはじめ
/*global module:false*/
module.exports = function(grunt) {
grunt.initConfig({
//ここから下に機能を分けて書くよ
// ベンダープレフィックスをつける機能 autoprefixer -------------------------
autoprefixer: {
options: {
},
concat: {