Skip to content

Instantly share code, notes, and snippets.

View musus's full-sized avatar

Susumu Seino musus

View GitHub Profile
@musus
musus / README.md
Created November 5, 2021 06:26 — forked from Nia-TN1012/README.md
WordPressにて、wp-content内の指定したファイルとディレクトリの所有者とパーミッションを設定するスクリプトです。

概要

WordPressのプラグインやテーマ、アップロードディレクトリ内の、ファイルとディレクトリの所有者及びパーミッションを設定するスクリプトです。

スクリプト

  • plugins.sh
  • themes.sh
  • uploads.sh

使い方(plugins.shでの例)

@musus
musus / deprecated.md
Created June 23, 2020 02:57 — forked from Rarst/deprecated.md
WordPress coding standards configuration for PhpStorm

Now Native

PhpStorm now bundles WordPress coding style natively, starting from version 8.

  1. Go to Project Settings > Code Style > PHP.
  2. Select Set From... (top right of window) > Predefined Style > WordPress.

No longer need to muck with this import! :)

function foo($path) {
// ここでなにかの処理
...;
}
function recursive($dir) {
if (!file_exists($dir)) {
return;
}
$dhandle = opendir($dir);
@musus
musus / behat-reference.feature
Created December 28, 2018 02:09 — forked from mnapoli/behat-reference.feature
Behat Mink reference
# Given
Given I am on [the] homepage
Given I am on "url"
# When
When I go to [the] homepage
When I go to "url"
When I reload the page
<?php
/**
* カスタムフィールドを定義
*
* @param array $settings MW_WP_Form_Setting オブジェクトの配列
* @param string $type 投稿タイプ or ロール
* @param int $id 投稿ID or ユーザーID
* @param string $meta_type post | user
*
* @return array
<?php
function wp_pagination()
{
global $wp_query;
$big = 99999999;
$page_format = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
<?php
if ($terms = get_the_terms($post->ID, 'release_cat')) {
foreach ( $terms as $term ) {
echo esc_html($term->name) ;
}
}
?>
<?php
if ($terms = get_the_terms($post->ID, 'release_cat')) {
foreach ( $terms as $term ) {
echo esc_html($term->name) ;
}
}
?>
add_action('init', 'register_blog_custom_post');
function register_blog_custom_post() {
register_post_type(
'blog', array(
'label' => 'ブログ',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
<?php $loop = new WP_Query( array('post_type' => 'post', 'posts_per_page' => 5 ) ); while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<span class="time"><?php the_time('Y年m月d日'); ?></span>
<?php the_title(); ?>
</a>
</li>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>