Skip to content

Instantly share code, notes, and snippets.

@seezee
seezee / webp.php
Last active November 25, 2022 22:28
WEBP for WordPress
<?php
/**
* Support for WEBP.
*
* @package myplugin
*/
// Security.
if ( ! defined( 'ABSPATH' ) ) {
die( 'Sorry, you are not allowed to access this page directly.' );
@mt8
mt8 / .babelrc
Last active September 5, 2019 03:23
Block Editor Handbook やるときのwebpack設定など
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
@torounit
torounit / Unminify.php
Created November 28, 2018 04:19
WordPress の管理画面で React が圧縮されるとデバッグがしづらいので、圧縮前のヤツを読み込むようにするプラグイン。
<?php
/**
* Plugin Name: Unminify vendor scripts.
*/
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
add_action( 'admin_print_scripts', function () {
global $wp_scripts;
unminify_execute( [
'react',
@torounit
torounit / functions.php
Created November 15, 2018 18:39
Gutenberg で選択出来るフォントサイズを変更。
<?php
add_action( 'after_setup_theme', function() {
add_theme_support('editor-font-sizes', [
[
'name' => 'Small',
'size' => 12,
'slug' => 'small'
],
[
@mt8
mt8 / mw-wp-form-count-limiter.php
Created March 23, 2018 20:23
[WordPress Plugin] MW WP Form Count Limiter
<?php
/*
* Plugin Name: MW WP Form Count Limiter
* Plugin URI: https://mt8.biz
* Description: MW WP Form のフォームごとに送信件数制限を設定できるようにするアドオン
* Version: 0.1
* Author: mt8
* Author URI: https://mt8.biz
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
<?php
/**
* Adds a title attribute to iframe oembeds
*
* @since 1.0.0
*
* @param string $html HTML
* @param string $url URL to embed
* @param array $attributes HTML Attributes
* @param int $post_id Post ID
@k4zuki02h4t4
k4zuki02h4t4 / .php
Created May 18, 2017 03:42
[WordPress] Play YouTube video inline on iOS.
<?php
/**
* Play YouTube video inline on iOS.
*/
add_filter( 'oembed_dataparse', function ( $return, $data ) {
if ( is_object( $data ) && 'YouTube' === $data->provider_name && ! empty( $data->html ) && is_string( $data->html ) ) {
$return = preg_replace( '/src="([^"]+)"/', 'src="$1&playsinline=1"', $data->html );
}
return $return;
@buchiya4th
buchiya4th / stylelint.config.js
Last active February 15, 2024 21:29
stylelintの設定ファイル
module.exports = {
plugins: ['stylelint-order', 'stylelint-scss'],
rules: {
indentation: 2,
'color-hex-case': 'lower', // hex値は小文字指定(大文字を禁止)
'color-hex-length': 'short', // hex値は短い表記(冗長な表記は禁止)
'color-named': 'never', // 名前付きカラー指定を禁止
'color-no-invalid-hex': true, // 無効な16進数の色指定を禁止
'function-comma-space-after': 'always-single-line', // 単一行のカンマ後には空白が必要
'function-comma-space-before': 'never', // カンマ前の空白を禁止
@fumikito
fumikito / request.php
Created March 2, 2017 08:07
A typical jQuery request to WordPress REST API
<?php
/**
* Regsiter script
*/
add_action( 'wp_enqueue_scripts', function() {
// Set dependency to wp-api, which has nonce and endpoint root.
wp_enqueue_script( 'api-handler', '/path/to/api-handler.js', [ 'jquery', 'wp-adpi' ], '1.0', true );
} );
@miya0001
miya0001 / wp-update.sh
Last active January 4, 2017 10:18
wp-cli
#!/usr/bin/env bash
set -eu
wp @all core verify-checksums
wp @all vackup create
wp @all core update
wp @all core language update
wp @all plugin update --all