カスタマイザーに changelog.txt を表示する

カスタマイザーで、オプション値の変更を伴う項目だけでなく、changelog等を表示したい場合、ちょっと工夫が必要そうなので、お試し版を書いてみます。
以下のコードは、カスタマイザーの「色」の一番下に表示されます。

twentyfifteen等で、changelog.txtをテーマホルダーに作成したうえで、動作確認をしてみてください。

functions.php

add_action( 'customize_register', 'my_customize_register' );

if ( !function_exists( 'my_customize_register' ) ) {

	function my_customize_register( $wp_customize ) {

		$wp_customize->add_setting( 'my_navigation_setting', array(
			'default'=> '',
			'type' => '',
			'capability' => 'edit_theme_options',
			'sanitize_callback'=> 'esc_html',
		) );
		$wp_customize->add_control( new Raindrops_Customize_Changelog_Control( $wp_customize, 'my_navigation_setting', array(
			'label'=> 'change log',
			'description' => '',
			'section'=> 'colors',
			'settings'=> 'my_navigation_setting',
			'priority'=> 20,
		) ) );
	}

}

if ( class_exists( 'WP_Customize_Control' ) ) {

	if ( !class_exists( 'Raindrops_Customize_Changelog_Control' ) ) {

		class Raindrops_Customize_Changelog_Control extends WP_Customize_Control {

			public $type= 'changelog';

			public function render_content() {
				$changelog_url= get_template_directory_uri() . '/changelog.txt';
				$part_data = wp_remote_get( $changelog_url );
				$part_data = esc_html( $part_data[ 'body' ] );
				$part_data = wpautop( $part_data );
				$html= '<div class="raindrops-changelog">
							<h4 class="raindrops-customize-content title">%1$s</h4>
							<div class="raindrops-recent-changes">%2$s</div>
							<p><a href="%3$s" target="_blank">%1$s</a></p>
						</div>';
				printf( $html, $this->label, $part_data, $changelog_url );
			}
		}
	}
}
[emulsion_relate_posts]