Skip to content

Instantly share code, notes, and snippets.

View s-hiroshi's full-sized avatar

Hiroshi Sawai s-hiroshi

View GitHub Profile
tr, td {
display: block;
width: 100%;
}
@s-hiroshi
s-hiroshi / connectmysql.php
Last active January 10, 2020 05:11
PHPでmysql_connect関数を使いMySQLへ接続するサンプルです。
<?php
// exampleデータベースにfield1, field2を持つtable1テーブルを作成済みの前提
// データベース接続情報
$url = "localhost";
$user = "root";
$password = "";
$database = "example";
// データベース接続処理
$connect = mysql_connect($url,$user,$password) or die("can't connect");
$db = mysql_select_db($database,$connect) or die("can't Select database");
@s-hiroshi
s-hiroshi / wp-category-tree.php
Last active August 4, 2019 02:48
WordPressでカテゴリーツリーを取得するサンプルです。
<?php
ini_set( 'xdebug.var_display_max_children', - 1 );
ini_set( 'xdebug.var_display_max_data', - 1 );
ini_set( 'xdebug.var_display_max_depth', - 1 );
$records = CategoriesTree::get_records_for_category_tree( 起点となるカテゴリーID, array() );
$data = CategoriesTree::set_records_for_category_tree( $records );
$tree = CategoriesTree::get_category_tree( $data[0], array( $data[1][0] ) );
var_dump( $tree );
?>
@s-hiroshi
s-hiroshi / README.md
Last active April 27, 2018 20:22
jQuery > snippet > dropdown

Condition

gte IE 8 and firefox, chrome, safari, opera latest version

Usage

<link rel="stylesheet" href="style.css" media="all">
@s-hiroshi
s-hiroshi / wp-eyecatch-images.md
Last active February 5, 2018 06:10
WordPress画像サイズをまとめたファイルです。

WordPressアイキャッチ画像メモ

サイズ設定

画像サイズ

画像サイズはthumbnail, medium, large, fullに加えアイキャッチが有効な場合はpost-thumbnailを指定できます。 (その他にも任意の幅、高さを配列で指定することも可)

  • 画像サイズ(ダッシュボード > 設定 > メディア)
@s-hiroshi
s-hiroshi / wp-loop-foreach.php
Last active February 25, 2017 07:12
Wordpress - スニペット - foreach文を使用した基本ループのサンプルです。
/**
* foreachを使ったサンプル
*
* reffer
* get_posts
* http://codex.wordpress.org/Template_Tags/get_posts
*/
<?php
$args = array(
'posts_per_page' => 5,
@s-hiroshi
s-hiroshi / class-head.php
Last active July 12, 2016 00:22
WordPressのセットアップ(InfoTown_Setup, InfoTown_Head、InfoTown_Admin、InfoTown_Post)クラスのサンプルです。
<?php
/**
* HEAD処理
*
* @package InfoTown
* @author Hiroshi Sawai <info@info-town.jp>
* @copyright Hiroshi Sawai
*/
class InfoTown_Head {
@s-hiroshi
s-hiroshi / class-admin.php
Created July 12, 2016 00:20
WordPressセットアップ(InfoTown_Admin、InfoTown_Post)のサンプルです。
<?php
/**
* 管理画面設定
*
* @package InfoTown
* @author Hiroshi Sawai <info@info-town.jp>
* @copyright Hiroshi Sawai
*/
class InfoTown_Admin {
// 管理者以外アップデート非表示
@s-hiroshi
s-hiroshi / test-wp-categories-utils.php
Last active June 16, 2016 10:34
WordPressの汎用的なカテゴリー処理をまとめたユーティリティークラスです。
<?php
/**
* InfoTown_Categories_Utilsのテストクラス
*
* @package InfoTown
* @subpackage tests
* @author Hiroshi Sawai <info@info-town.jp>
* @copyright Hiroshi Sawai
* @version 1.0.0
* @since 1.0.0
@s-hiroshi
s-hiroshi / test-wp-utils-page.php
Last active May 25, 2016 03:21
WordPressで汎用的にページ(page)を処理するユーティリティークラスです。
<?php
/**
* InfoTown_Utils_Pagesテスト
*
* @package InfoTown
* @author Hiroshi Sawai <info@info-town.jp>
* @copyright Hiroshi Sawai
*/
class InfoTown_Utils_Pages_Test extends WP_UnitTestCase {