詳しく上記記事を書いたのでそちらへ。
Hello Dollyをカスタマイズしてみた。
<?php
/**
* @package Hello Yuu via hello-dolly
* @version 0.1.1
*/
/*
Plugin Name: Hello Yuu via hello-dolly
Plugin URI: http://example.com/plugins/hello-yuu/
Description: Plugin development tutorial
Author: Kanehiro Yuu
Version: 0.1.1
Author URI: https://sys-guard.com/
*/
class Say_Hello
{
private $sghello = "";
private $chosen = "";
private $x = "";
public function __construct(){
$this->admin_init();
}
//フックを実行
public function admin_init(){
add_action( 'admin_notices', array($this, 'hello_yuu') );
add_action( 'admin_head', array($this, 'hello_yuu_css') );
add_shortcode('SG-Hello', array($this, 'hello_yuu') );
}
//挨拶関数 入力します
public function sg_hello_get_words() {
/** These are the lyrics to Hello Dolly */
$sghello = "Hello, Yuu";
return $sghello;
}
//挨拶関数 出力します
public function hello_yuu() {
$chosen = $this->sg_hello_get_words();
echo "<p id='dolly'>$chosen</p>";
}
//挨拶関数 CSS装飾
public function hello_yuu_css() {
// This makes sure that the positioning is also good for right-to-left languages
$x = is_rtl() ? 'left' : 'right';
echo "
<style type='text/css'>
#dolly {
float: $x;
padding-$x: 15px;
padding-top: 5px;
margin: 0;
font-size: 11px;
}
</style>
";
}
}
//実行するよ!
$Aisatu = new Say_Hello();
WordPressのプラグイン作成の入門記事を作るために作成。
Hello Dollyをベースにクラス化しました。

![CET リアルタイム集計・分析基盤 構成メモ[NOINDEX]](https://www.yuulinux.tokyo/contents/wp-content/uploads/2017/11/plan_20181101_0-150x150.png)
