<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>サイズ &#8211; WordPress Memo</title>
	<atom:link href="https://blog.riverforest-wp.info/tag/%E3%82%B5%E3%82%A4%E3%82%BA/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.riverforest-wp.info</link>
	<description>WordPress に関する覚え書き</description>
	<lastBuildDate>Fri, 09 May 2025 12:48:52 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://blog.riverforest-wp.info/wp-content/uploads/2018/05/cropped-icon-256x256-1-32x32.png</url>
	<title>サイズ &#8211; WordPress Memo</title>
	<link>https://blog.riverforest-wp.info</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>フォルダー内のコードの総行数とサイズを調べる</title>
		<link>https://blog.riverforest-wp.info/folder-code-line-zise/</link>
		
		<dc:creator><![CDATA[Katsushi Kawamori]]></dc:creator>
		<pubDate>Sun, 22 Aug 2021 02:57:20 +0000</pubDate>
				<category><![CDATA[Function]]></category>
		<category><![CDATA[コード]]></category>
		<category><![CDATA[サイズ]]></category>
		<category><![CDATA[行数]]></category>
		<guid isPermaLink="false">https://blog.riverforest-wp.info/?p=2851</guid>

					<description><![CDATA[はじめに 今回の記事は、ちょっとしたお遊び記事です。 作成した公式プラグインが、気づいたら「１００万ダウンロード」と「５万以上サイトで有効化中」になっていました。この数値は、Plugin Stats View という私の [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">はじめに</h3>



<p class="wp-block-paragraph">今回の記事は、ちょっとしたお遊び記事です。</p>



<p class="wp-block-paragraph">作成した公式プラグインが、気づいたら「<strong>１００万ダウンロード</strong>」と「<strong>５万以上サイトで有効化中</strong>」になっていました。この数値は、<strong>Plugin Stats View</strong> という私のプラグインで出したもので、<strong>plugins_api</strong> を利用して集計しています。</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-3a88641f wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure data-wp-context="{&quot;imageId&quot;:&quot;6a0e2e6f28a97&quot;}" data-wp-interactive="core/image" data-wp-key="6a0e2e6f28a97" class="wp-block-image size-full wp-lightbox-container"><img fetchpriority="high" loading="eager" decoding="async" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" width="324" height="253" src="https://blog.riverforest-wp.info/wp-content/uploads/20210822/Screenshot-2021-08-22-at-11-21-08-Riverforest-Plugins.png" alt="" class="wp-image-2856" srcset="https://blog.riverforest-wp.info/wp-content/uploads/20210822/Screenshot-2021-08-22-at-11-21-08-Riverforest-Plugins.png 324w, https://blog.riverforest-wp.info/wp-content/uploads/20210822/Screenshot-2021-08-22-at-11-21-08-Riverforest-Plugins-300x234.png 300w" sizes="(max-width: 324px) 100vw, 324px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<style>
.simpleblogcard_img_blockd3b222eb4178710f299c86e5078f2bf5 {
  float: right;
  padding: 10px;
}
.simpleblogcard_borderd3b222eb4178710f299c86e5078f2bf5 {
  border-left: solid 8px #cd162c;
  padding: 0.25em 0.25em;
  background: transparent;
}
.simpleblogcard_titled3b222eb4178710f299c86e5078f2bf5 {
  line-height: 155%;
  font-weight: bold;
  display: block;
}
.simpleblogcard_descriptiond3b222eb4178710f299c86e5078f2bf5 {
  line-height: 155%;
  color: #333;
}
</style>
<div class="simpleblogcard_wrap">
			<a style="text-decoration: none;" href=https://ja.wordpress.org/plugins/plugin-stats-view/>
			<div class="simpleblogcard_inner">
		<div class="simpleblogcard_borderd3b222eb4178710f299c86e5078f2bf5">
			ja.wordpress.org			<div class="simpleblogcard_titled3b222eb4178710f299c86e5078f2bf5">
				Plugin Stats View – WordPress プラグイン | WordPress.org 日本語			</div>
							<div class="simpleblogcard_descriptiond3b222eb4178710f299c86e5078f2bf5">
					プラグイン情報をブロックあるいはショートコードで表示します。				</div>
					</div>
	</div>
	<div style="clear: both;"></div>
	</a>
</div>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<style>
.simpleblogcard_img_block9f1b81a277aac5efbd6e650fb3e83427 {
  float: right;
  padding: 10px;
}
.simpleblogcard_border9f1b81a277aac5efbd6e650fb3e83427 {
  border-left: solid 8px #cd162c;
  padding: 0.25em 0.25em;
  background: transparent;
}
.simpleblogcard_title9f1b81a277aac5efbd6e650fb3e83427 {
  line-height: 155%;
  font-weight: bold;
  display: block;
}
.simpleblogcard_description9f1b81a277aac5efbd6e650fb3e83427 {
  line-height: 155%;
  color: #333;
}
</style>
<div class="simpleblogcard_wrap">
			<a style="text-decoration: none;" href=https://developer.wordpress.org/reference/functions/plugins_api/>
				<figure class="simpleblogcard_img_block9f1b81a277aac5efbd6e650fb3e83427">
			<img decoding="async" style="border-radius: 5px; width: 100px; height: 52px;" src="https://developer.wordpress.org/wp-content/themes/wporg-developer-2023/images/opengraph-image.png" alt="plugins_api() – Function | Developer.WordPress.org" />
		</figure>
		<div class="simpleblogcard_inner">
		<div class="simpleblogcard_border9f1b81a277aac5efbd6e650fb3e83427">
			developer.wordpress.org			<div class="simpleblogcard_title9f1b81a277aac5efbd6e650fb3e83427">
				plugins_api() – Function | Developer.WordPress.org			</div>
							<div class="simpleblogcard_description9f1b81a277aac5efbd6e650fb3e83427">
					Retrieves plugin installer pages from the WordPress.org Plugins API.				</div>
					</div>
	</div>
	<div style="clear: both;"></div>
	</a>
</div>
</div>
</div>



<p class="wp-block-paragraph">ここまで良くやったなあとは思いつつ、今まで何行書いたんだろうと思い、行数とサイズを調べるプログラムを php で作成してみました。</p>



<h3 class="wp-block-heading">下準備 &amp; 仕様</h3>



<p class="wp-block-paragraph">作業ディレクトリを作成し、６６個のプラグインをコピーしました。あらかじめ、自分以外の方が書いたライブラリなどを削除しました。</p>



<ul class="wp-block-list"><li>コマンドライン上で実行します。</li><li>コード中に指定したディレクトリを再帰検索して、php, js , css ファイルをカウントします。</li><li>php, js, css のそれぞれと全ての行数の総和と、サイズの総和を出力します。</li></ul>



<h3 class="wp-block-heading">コード</h3>



<pre class="prism line-numbers"><code class="language-php language-html">&lt;?php
/**
 * Plugin Name: Program number of line
 * Author:      Katsushi Kawamori
 * Author URI:  https://riverforest-wp.info/
 * License:     GPL2
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 *
 */

/*
	Copyright (c) 2021- Katsushi Kawamori (email : dodesyoswift312@gmail.com)
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; version 2 of the License.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

$line_all = pnol_scan_file( 'ディレクトリをフルパスで指定します' );

foreach ( $line_all as $key =&gt; $value ) {
	echo $key . ' : ' . number_format( $value&#91;'line'] ) . '行 - ' . number_format( $value&#91;'size'] / 1024 / 1024, 2 ) . 'Mbyte' . PHP_EOL;
}

echo PHP_EOL;

/** ==================================================
 * Scan file
 *
 * @param string $dir  dir.
 * @return array $count
 * @since 1.00
 */
function pnol_scan_file( $dir ) {

	$iterator = new RecursiveDirectoryIterator(
		$dir,
		FilesystemIterator::CURRENT_AS_FILEINFO |
		FilesystemIterator::KEY_AS_PATHNAME |
		FilesystemIterator::SKIP_DOTS
	);
	$iterator = new RecursiveIteratorIterator( $iterator );
	$iterator = new RegexIterator( $iterator, '/\.php$|\.js$|\.css$/i', RecursiveRegexIterator::MATCH );

	$count = array(
		'all' =&gt; array(
			'line' =&gt; 0,
			'size' =&gt; 0,
		),
		'php' =&gt; array(
			'line' =&gt; 0,
			'size' =&gt; 0,
		),
		'js' =&gt; array(
			'line' =&gt; 0,
			'size' =&gt; 0,
		),
		'css' =&gt; array(
			'line' =&gt; 0,
			'size' =&gt; 0,
		),
	);
	if ( ! empty( $iterator ) ) {
		foreach ( $iterator as $file_path =&gt; $file_info ) {
			if ( $file_info-&gt;isFile() ) {
				$line = exec( 'wc -l '. $file_path );
				$count&#91;'all']&#91;'line'] += trim( str_replace( $file_path, '', $line ) );
				$count&#91;'all']&#91;'size'] += $file_info-&gt;getSize();
				switch ( $file_info-&gt;getExtension() ) {
					case 'php':
						$count&#91;'php']&#91;'line'] += trim( str_replace( $file_path, '', $line ) );
						$count&#91;'php']&#91;'size'] += $file_info-&gt;getSize();
						break;
					case 'js':
						$count&#91;'js']&#91;'line'] += trim( str_replace( $file_path, '', $line ) );
						$count&#91;'js']&#91;'size'] += $file_info-&gt;getSize();
						break;
					case 'css':
						$count&#91;'css']&#91;'line'] += trim( str_replace( $file_path, '', $line ) );
						$count&#91;'css']&#91;'size'] += $file_info-&gt;getSize();
						break;
				}
			}
		}
	}

	return $count;

}

?&gt;</code></pre>



<h3 class="wp-block-heading">実行</h3>



<p class="wp-block-paragraph">以下の様な結果になりました。</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6a0e2e6f29c71&quot;}" data-wp-interactive="core/image" data-wp-key="6a0e2e6f29c71" class="wp-block-image size-full wp-lightbox-container"><img loading="lazy" decoding="async" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" width="328" height="125" src="https://blog.riverforest-wp.info/wp-content/uploads/20210822/pgnol.png" alt="" class="wp-image-2855" srcset="https://blog.riverforest-wp.info/wp-content/uploads/20210822/pgnol.png 328w, https://blog.riverforest-wp.info/wp-content/uploads/20210822/pgnol-300x114.png 300w" sizes="auto, (max-width: 328px) 100vw, 328px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button></figure>



<h3 class="wp-block-heading">終わりに</h3>



<p class="wp-block-paragraph">最近、自プロダクトの「<strong>競技会採点システム</strong>」の方に時間を割く事が多くなったので、今後、公式プラグインの方はあまり力を入れないと思います。フォーラムで応答が無くても、ご容赦ください。</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-3a88641f wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<style>
.simpleblogcard_img_blockb3eeb6434bfc0359f035d76d60866f48 {
  float: right;
  padding: 10px;
}
.simpleblogcard_borderb3eeb6434bfc0359f035d76d60866f48 {
  border-left: solid 8px #cd162c;
  padding: 0.25em 0.25em;
  background: transparent;
}
.simpleblogcard_titleb3eeb6434bfc0359f035d76d60866f48 {
  line-height: 155%;
  font-weight: bold;
  display: block;
}
.simpleblogcard_descriptionb3eeb6434bfc0359f035d76d60866f48 {
  line-height: 155%;
  color: #333;
}
</style>
<div class="simpleblogcard_wrap">
			<a style="text-decoration: none;" href=https://compe-scoring.com/>
			<div class="simpleblogcard_inner">
		<div class="simpleblogcard_borderb3eeb6434bfc0359f035d76d60866f48">
			compe-scoring.com			<div class="simpleblogcard_titleb3eeb6434bfc0359f035d76d60866f48">
				Competition Scoring System – Competition Scoring System			</div>
							<div class="simpleblogcard_descriptionb3eeb6434bfc0359f035d76d60866f48">
					Features of the Service This service is a scoring system for competitions or contests. Aut&#8230;				</div>
					</div>
	</div>
	<div style="clear: both;"></div>
	</a>
</div>
</div>
</div>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
