Skip to content

Instantly share code, notes, and snippets.

View tekapo's full-sized avatar

Tai / JOTAKI Taisuke tekapo

View GitHub Profile
@skorasaurus
skorasaurus / example1.md
Last active November 11, 2023 17:19
Manage WordPress via WP-CLI with these Shortcuts/scripts/functions/aliases.

update text inside a post (we work with 3rd party vendors, their urls occasionally change; or we changed a campaign's name used in google analytics) and limit it to ONLY published posts. (sometimes, our marketing team wants to what see how content was EXACTLY in the past). wp-cli's search-replace command by default make edits in revisions.

(in this command, 'before' is what you want to get rid of and 'after' is what you want to replace 'before' with.

wp db query "UPDATE $(wp db tables "*_posts") SET post_content = REPLACE(post_content, 'before', 'after') WHERE post_status = 'publish';"

@wokamoto
wokamoto / replace-siteurl.php
Created September 4, 2012 23:22
WordPress のDB上のサイトURLを一気に変換
#!/usr/bin/php
<?php
switch($argc) {
case 1:
case 2:
echo "please input new site url and wp directory name!\n";
exit();
default:
$old_site = isset($argv[3]) ? $argv[3] : '';
$path = $argv[2];
@hughc
hughc / gutenberg-audit.php
Created April 20, 2020 10:36
Gutenberg Audit for WordPress
<?php
/*
Plugin Name: Gutenberg Audit
Plugin URI: http://highbrow.com.au/plugins/gutenberg-audit
description: What blocks is your site using?
Version: 0.1
Author: Hugh Campbell
Author URI: http://highbrow.com.au/
License: GPL2
*/
@tetsuharu-kono
tetsuharu-kono / wifi_site_survey.sh
Last active January 30, 2023 00:14
Wi-Fi site survey script for macOS
#!/bin/zsh
# Wi-Fi Site Survey
# 2020.07.22 Rev. 0.1
# First release
# 2023.01.30 Rev. 0.2
# Fixed channel and BSSID not being retrieved by Monterey
# Fail on unset variables and command errors
set -ue -o pipefail
@salcode
salcode / .editorconfig
Last active October 15, 2022 21:22
WordPress .editorconfig - modified version of the WordPress coding standards
# EditorConfig helps keep your project formatting consistent.
# See https://EditorConfig.org
#
# This is a modified version of the WordPress coding standards.
#
# Author: Sal Ferrarello (@salcode)
# https://salferrarello.com/wordpress-editorconfig/
#
# You can download this file directly
# to your project from the command-line with
@gatespace
gatespace / view_template_files.php
Last active July 30, 2022 22:04
WordPressのテーマにおいて、テンプレート階層に基づきどのテンプレートファイルが使われているか書き出すコード。 WordPressがデバッグモードのときのみ表示します。 使っているテンプレートファイルはグローバル変数 $template に保存されています。 (ただし、header.php や get_template_part などでインクルードされているファイルを除く) wp_footerにフックする形で関数が実行されますので、テーマのfunctions.phpの適当な箇所に追記してください。
/*
WordPressのテーマにおいて、テンプレート階層に基づきどのテンプレートファイルが使われているか書き出すコード。
ただし、header.php や get_template_part などでインクルードされているファイルを除く。
*/
add_action('wp_footer', 'view_template_files');
if ( !function_exists( 'view_template_files' ) ):
function view_template_files() {
if ( defined('WP_DEBUG') && WP_DEBUG ) {
global $template;
@markjaquith
markjaquith / disable-plugins-when-doing-local-dev.php
Created June 24, 2011 10:24
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@jonathonbyrdziak
jonathonbyrdziak / example.php
Created February 22, 2012 02:27
Wordpress Metabox, stand alone class for multiple metabox abilities
<?php
/*
Here's a couple of metaboxes that I've recently created using this system
*/
$subpostings = redrokk_metabox_class::getInstance('subpostings', array(
'title' => '(optional) Subscription for Postings',
'description' => "As an optional feature, you have a complete api at your disposal which will allow you the ability to offer and manage member posts. In addition to these settings, you may need to create the associated pages for accepting posts from your frontend.",
@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 ] || '';
}, [] );
@miya0001
miya0001 / hatamoto.php
Last active May 21, 2019 05:28
汎用的な管理画面付きのWordPressプラグインのテンプレート
<?php
/**
* Plugin Name: Hatamoto
* Plugin URI: https://wpist.me/
* Description: This is a awesome cool plugin.
* Version: 0.1.0
* Author: Takayuki Miyauchi
* Author URI: https://wpist.me/
* License: GPLv2
* Text Domain: hatamoto