Skip to content

Instantly share code, notes, and snippets.

@miya0001
miya0001 / gist:2864806
Created June 3, 2012 19:54
リバースプロキシやCDN,キャッシュ系のプラグインと仲良しで子テーマにも対応しやすいCSSの読み込み方
<link rel="stylesheet" type="text/css" media="all" href="<?php echo get_template_directory_uri(); ?>/style.css?ver=<?php echo filemtime(get_template_directory().'/style.css'); ?>" />
<?php if (is_child_theme()): ?>
<link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css?ver=<?php echo filemtime(get_stylesheet_directory().'/style.css') ?>" />
<?php endif; ?>
@wokamoto
wokamoto / example.com.conf
Created October 4, 2012 15:50
網元用 サブドメイン型マルチサイト WP nginx 設定例
server {
listen 80;
server_name example.com *.example.com;
root /var/www/vhosts/example.com;
index index.html index.htm;
charset utf-8;
access_log /var/log/nginx/example.com.access.log main;
error_log /var/log/nginx/example.com.error.log;
@wokamoto
wokamoto / example.com.backend.conf
Created October 4, 2012 15:51
網元用 サブドメイン型マルチサイト WP nginx 設定例 (backend.conf)
server {
listen unix:/var/run/nginx-backend.sock;
server_name example.com *.example.com;
root /var/www/vhosts/example.com;
index index.php index.html index.htm;
access_log /var/log/nginx/example.com.backend.access.log backend;
keepalive_timeout 25;
port_in_redirect off;
@miya0001
miya0001 / gist:3858804
Created October 9, 2012 13:26
WordPressでattachmentのページとかボタンを消す!
<?php
new disable_attachment_page();
class disable_attachment_page {
function __construct()
{
add_action("template_redirect", array(&$this, "template_redirect"));
add_action("admin_print_styles", array(&$this, "admin_print_styles"));
@wokamoto
wokamoto / thumbnail_noimage.php
Created November 27, 2012 10:28
[WordPress] サムネイルが無い場合に、メディアライブラリに登録されている特定の画像を出す奴
<?php
function thumbnail_noimage($html, $post_id, $post_thumbnail_id, $size, $attr) {
if (!empty($html))
return $html;
$post_thumbnail_id = 1234; // default thumbnail image id
$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
return $html;
}
@wokamoto
wokamoto / replace-post_type.sql
Created November 28, 2012 04:47
[WordPress] 特定のカテゴリに属する投稿を任意のカスタム投稿タイプに変換する SQL
-- カテゴリー 4 の投稿を、カスタム投稿タイプ photo に
update wp_posts
set post_type = 'photo'
where post_type = 'post'
and exists
(select object_id
from wp_term_taxonomy as t
inner join wp_relationships as r on t.term_taxonomy_id = r.term_taxonomy_id
where t.term_id = 4
and r.object_id = wp_posts.ID);
@wokamoto
wokamoto / attachment_link_convert.php
Created November 28, 2012 06:20
[WordPress] 画像のリンク先を強制的に添付ファイル投稿URLに変更する奴
@pimpmywp
pimpmywp / pm-trace-included-files.php
Last active April 1, 2016 15:58
[WordPress] インクルードされたテーマ関連ファイルをDebug Bar(Extender)の Variable Lookup で確認できるようにする。 ※テーマのフッターで wp_footer(); していること。
<?php
add_action( 'wp_footer', 'pm_trace_included_files' );
function pm_trace_included_files() {
$includeds = array_values(
str_replace(
get_theme_root()
, ""
, array_filter(
get_included_files()
, create_function( '$f', 'return 0 === strpos( $f, get_theme_root() );' )
/* The Grid ---------------------- */
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row.large-collapse .column,
.lt-ie9 .row.large-collapse .columns { padding: 0; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row .row.large-collapse { margin: 0; }
.lt-ie9 .column, .lt-ie9 .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; }
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; }
@miya0001
miya0001 / Makefile
Created April 15, 2013 07:27
@Mako0901 さん作の プラグインの翻訳ファイル用makefile
# パッケージ名
PACKAGE = wp-total-hacks
# パッケージのタイプ。plugin または theme
PROJECT = plugin
# 本家 (url) より入手してインストールしておいたもの
MAKEPOT = $(HOME)/wordpress-i18n-tools/makepot.php
PHP = /usr/bin/php
MSGMERGE = /usr/bin/msgmerge