Skip to content

Instantly share code, notes, and snippets.

@westonruter
westonruter / trac-39128-customizer-cross-domain-workaround.php
Last active July 25, 2023 02:37
WordPress Plugin for Customizer Cross-Domain Workaround (Trac #39128)
<?php
/**
* Plugin Name: Customizer Cross-Domain Workaround (Trac #39128)
* Description: Force customizer preview to use siteurl instead of home URL to work around Trac #39128. Temp fix for issue loading customizer preview when home and siteurl have different domains (cross-domain).
* Plugin URI: https://core.trac.wordpress.org/ticket/39128
* Author: Weston Ruter, XWP
* Author URI: https://make.xwp.co/
*
* Copyright (c) 2017 XWP (https://xwp.co/)
*
<?php
/**
* Smart Custom Fieldsの定義用クラス
* グループごとにメソッドを作ると良い
*
* @link https://2inc.org/blog/2015/03/12/4670/
*/
Class Test_SmartCustomFields {
@inc2734
inc2734 / .php
Created November 11, 2015 01:27
Register custom post type on Habakiri
<?php
function habakiri_child_theme_setup() {
class Habakiri extends Habakiri_Base_Functions {
public function __construct() {
parent::__construct();
add_action( 'init', array( $this, 'register_post_types' ) );
}
/**
* カスタム投稿タイプを定義
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active March 13, 2024 17:43
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@hissy
hissy / rscsv-divide-meta-fields.php
Created April 6, 2015 01:29
Divide Meta Fields with Comma (Really Simple CSV Importer add-on)
<?php
/*
Plugin Name: Divide Meta Fields with Comma (Really Simple CSV Importer add-on)
*/
add_filter('really_simple_csv_importer_save_meta', function($meta, $post, $is_update) {
foreach ($meta as $key => $value) {
if (strpos($value, ',') !== false) {
$_value = preg_split("/,+/", $value);
$meta[$key] = $_value;
@inc2734
inc2734 / gist:9f6d65c7473d060d0fd6
Last active April 30, 2022 09:26
smart-cf-register-fields のサンプル
<?php
/**
* カスタムフィールドを定義
*
* @param array $settings Smart_Custom_Fields_Setting オブジェクトの配列
* @param string $type 投稿タイプ or ロール
* @param int $id 投稿ID or ユーザーID
* @param string $meta_type post | user
* @return array
*/
@hissy
hissy / gist:0b8df0149fbba16be08d
Last active March 21, 2023 02:15
[Really Simple CSV Importer] 画像をインターネットからダウンロードして投稿に添付し、画像のIDをカスタムフィールドに登録
<?php
/*
Plugin Name: Really Simple CSV Importer Action add-on
Description: Run the additional action after importing the post data
Author: Takuro Hishikawa
Version: 0.1
*/
class rscsvimporter_action {
// singleton instance
@miya0001
miya0001 / gist:db3ce191e31871964a57
Last active October 21, 2017 02:14
テーマレビュワーのためのVCCW裏ワザ

初期設定

$ mkdir -p ~/vagrants/vccw
$ cd ~/vagrants/vccw
$ git clone git@github.com:miya0001/vccw.git .

次に以下のコードを~/.bash_profileに登録

@tkc49
tkc49 / gist:e1114c0e7203cb1a37bc
Last active August 16, 2017 06:21
タームをカスタマイズする際に必要なフック
<?php
public function plugins_loaded(){
add_action ( 'edited_term',array($this,'save_extra_category_fileds')); // 編集画面の保存
add_action ( 'created_term',array($this,'save_extra_category_fileds')); // 新規追加の保存
}
public function init(){
$args=array('public' => true,'_builtin' => false ); // builtin=false(WordPressが設定してるものは省く)
$output = 'names'; // or objects
@beijaflor
beijaflor / config.rb
Created April 14, 2014 16:12
compass setting to ask overwrite when it build as :production
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "img"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):