<?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/%E6%83%85%E5%A0%B1/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=6.9.4</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/my-plugin-info/</link>
		
		<dc:creator><![CDATA[Katsushi Kawamori]]></dc:creator>
		<pubDate>Thu, 27 Oct 2022 11:06:24 +0000</pubDate>
				<category><![CDATA[Function]]></category>
		<category><![CDATA[プラグイン]]></category>
		<category><![CDATA[情報]]></category>
		<guid isPermaLink="false">https://blog.riverforest-wp.info/?p=3002</guid>

					<description><![CDATA[はじめに プラグインの開発者には、新たなバージョンの WordPress がリリースされる前に、Tested up to:(検証済み最新バージョン:)の値を確認するように、以下の様なメールが届きます。同じ事をやってみよう [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">はじめに</h3>



<p>プラグインの開発者には、新たなバージョンの WordPress がリリースされる前に、Tested up to:(検証済み最新バージョン:)の値を確認するように、以下の様なメールが届きます。同じ事をやってみようと思いコードを書いてみました。</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;69cc63647e63f&quot;}" data-wp-interactive="core/image" data-wp-key="69cc63647e63f" 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-window--resize="callbacks.setButtonStyles" width="548" height="439" src="https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-testedupto.png" alt="" class="wp-image-3005" srcset="https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-testedupto.png 548w, https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-testedupto-300x240.png 300w" sizes="(max-width: 548px) 100vw, 548px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			aria-label="拡大する"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.imageButtonRight"
			data-wp-style--top="state.imageButtonTop"
		>
			<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>プラグイン単体の場合は、<a href="https://developer.wordpress.org/reference/functions/plugins_api/">plugins_api</a> で取得できます。全プラグインの情報の場合、取得できる関数が見当たらないので、プロフィールサイトから取得する事にしました。プロフィールサイトには以下の様に各プラグインのリンクにスタイルをあてるクラス「<strong>plugin-info-container</strong>」があったので、そこからスクレイピングしました。</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;69cc63647ed08&quot;}" data-wp-interactive="core/image" data-wp-key="69cc63647ed08" class="wp-block-image size-large wp-lightbox-container"><img loading="lazy" decoding="async" width="1024" height="568" 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-window--resize="callbacks.setButtonStyles" src="https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-133305-1024x568.png" alt="" class="wp-image-3001" srcset="https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-133305-1024x568.png 1024w, https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-133305-300x166.png 300w, https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-133305-768x426.png 768w, https://blog.riverforest-wp.info/wp-content/uploads/20221027/2022-10-27-133305.png 1520w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			aria-label="拡大する"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.imageButtonRight"
			data-wp-style--top="state.imageButtonTop"
		>
			<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>



<p>WordPress の関数を使えるように、<strong>wp-load.php</strong> を読み込めるようにしました。</p>



<p>また、コマンドラインオプションを設け、プラグイン単体での各属性を取得できるようにしました。各属性に関しては、<a href="https://developer.wordpress.org/reference/functions/plugins_api/">plugins_api</a> を参照してください。</p>



<p>以下に動作を動画（倍速）で示します。</p>



<figure class="wp-block-video"><video height="628" style="aspect-ratio: 1116 / 628;" width="1116" controls muted src="https://blog.riverforest-wp.info/wp-content/uploads/20221027/profiles-plugins.mp4"></video></figure>



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



<pre class="prism line-numbers"><code class="language-php language-html">&lt;?php
/**
 * Name:        profiles-plugins.php
 * Version:     1.00
 * Author:      Katsushi Kawamori
 * Author URI:  https://riverforest-wp.info/
 * License:     GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 *
 * @package     profiles-plugins
 */

/* Your WordPress profile url */
const WP_PROFILE_URL = 'https://profiles.wordpress.org/katsushi-kawamori/';

/* Wp load. This file =&gt; wp-content/uploads/profiles-plugins.php */
list( $abspath, $mypath ) = explode( 'wp-content', dirname( __FILE__ ), 2 );
$wp_load_path = $abspath . 'wp-load.php';
require_once( $wp_load_path );

/* For plugins_api */
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';

$cmdoptions = array();
/* Example -a active_installs -p woocommerce */
$cmdoptions = getopt( 'a:p:' );

/* Default atribute 'tested' */
if ( isset( $cmdoptions&#91;'a'] ) &amp;&amp; ! empty( $cmdoptions&#91;'a'] ) ) {
	$atr = $cmdoptions&#91;'a'];
} else {
	$atr = 'tested';
}

if ( isset( $cmdoptions&#91;'p'] ) &amp;&amp; ! empty( $cmdoptions&#91;'p'] ) ) {
	$slug = $cmdoptions&#91;'p'];
	$plugin_s = array(
		'name' =&gt; read_plugins_api( $slug, 'name' ),
		'link' =&gt; read_plugins_api( $slug, 'homepage' ),
		'slug' =&gt; $slug,
		$atr =&gt; read_plugins_api( $slug, $atr ),
	);
	print_r( $plugin_s );
} else {
	/* Scraping */
	$dom = new DOMDocument( '1.0', 'UTF-8' );
	$html = file_get_contents( WP_PROFILE_URL );
	@$dom-&gt;loadHTML( $html );
	$xpath = new DOMXpath( $dom );
	/* Get &lt;a&gt; tag within class plugin-info-container */
	$a_tags = $xpath-&gt;query( '//div&#91;@class="plugin-info-container"]&#91;1]//a' );
	$count = 0;
	foreach ( $a_tags as $node ) {
		/* Get href attribute from within &lt;a&gt; tag */
		$link_url = 'https:' . $node-&gt;getAttribute( 'href' );
		/* Get slug from URL */
		$link_s = untrailingslashit( $link_url );
		$links = explode( '/', $link_s );
		$slug = end( $links );

		++$count;
		$plugin_s = array(
			'count' =&gt; $count,
			'name' =&gt; $node-&gt;nodeValue,
			'link' =&gt; $link_url,
			'slug' =&gt; $slug,
			$atr =&gt; read_plugins_api( $slug, $atr ),
		);
		print_r( $plugin_s );
	}
}

/** ==================================================
 * Get api and value
 *
 * @param string $slug  slug.
 * @param string $atr  atribute.
 * @return mixed api value.
 * @since 1.00
 */
function read_plugins_api( $slug, $atr ) {

	/* Call API */
	$call_api = plugins_api(
		'plugin_information',
		array(
			'slug' =&gt; $slug,
			'fields' =&gt; array(
				'short_description' =&gt; true,
				'description' =&gt; true,
				'active_installs' =&gt; true,
				'downloaded' =&gt; true,
				'icons' =&gt; true,
				'banners' =&gt; true,
				'ratings' =&gt; true,
			),
		)
	);

	return $call_api-&gt;$atr;

}</code></pre>
]]></content:encoded>
					
		
		<enclosure url="https://blog.riverforest-wp.info/wp-content/uploads/20221027/profiles-plugins.mp4" length="6436233" type="video/mp4" />

			</item>
	</channel>
</rss>
