Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
WordPress関数の使い方でみるPHPの文法おさらい 20170816 in いろいろ初心...
Search
echizenyayota
August 15, 2017
Technology
110
0
Share
WordPress関数の使い方でみるPHPの文法おさらい 20170816 in いろいろ初心者もくもく会
WordPress関数の使い方でみるPHPの文法おさらい 20170816 in いろいろ初心者もくもく会
echizenyayota
August 15, 2017
More Decks by echizenyayota
See All by echizenyayota
日本語話者と英語話者のためのIT技術者交流コミュニティ_事始め_日本語_英語_.pdf
echizenyayota
0
470
外出自粛期間のおすすめ! オンラインサービスで 自由気ままな英語学習
echizenyayota
0
560
Visual Studio CodeでJavaScriptプログラミング
echizenyayota
0
340
他人のソースコードをすばやく読むコツ 項とJavaScriptの演算子
echizenyayota
0
130
ドットインストールの質問回答サービスで身につくプログラミング学習法
echizenyayota
0
150
「Webパフォーマンス改善セミナー」 概要説明
echizenyayota
1
76
JavaScriptの正規表現で リファラースパムを退治した話
echizenyayota
0
150
JavaScriptの新しい文法を学習しよう
echizenyayota
1
350
さくらのVPSでプラグインを使わないWordPressのバックアップ
echizenyayota
0
1.5k
Other Decks in Technology
See All in Technology
バイブコーディングで3倍早く⚪⚪を作ってみた
samakada
0
110
UIライブラリに依存しすぎないReact Native設計を目指して
grandbig
0
100
The Journey of Box Building
tagomoris
4
3.2k
ぼくがかんがえたさいきょうのあうとぷっと
yama3133
0
200
音声言語モデル手法に関する発表の紹介
kzinmr
0
120
弁護士ドットコム株式会社 エンジニア職向け 会社紹介資料
bengo4com
1
160
実践ハーネスエンジニアリング:TAKTで実現するAIエージェント制御 / Practical Harness Engineering: AI Agent Control Enabled by TAKT
nrslib
12
4.7k
Pure Intonation on Browser: Building a Sequencer with Ruby
nagachika
0
140
Keeping Ruby Running on Cygwin
fd0
0
170
M5Stack CoreS3とZephyr(RTOS)で Edge AIっぽいことしてみた
iotengineer22
0
270
「誰一人取り残されない」 AIエージェント時代のプロダクト設計思想 Product Management Summit 2026
mizushimac
1
640
最近の技術系の話題で気になったもの色々(IoT系以外も) / IoTLT 花見予定会(たぶんBBQ) @都立潮風公園バーベキュー広場
you
PRO
1
240
Featured
See All Featured
Claude Code のすすめ
schroneko
67
220k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Thoughts on Productivity
jonyablonski
76
5.1k
Context Engineering - Making Every Token Count
addyosmani
9
840
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Typedesign – Prime Four
hannesfritz
42
3k
Believing is Seeing
oripsolob
1
110
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
800
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Transcript
WordPress関数の使い方でみる PHPの文法おさらい 2017年8月16日(水) in JUSO Coworking
Who are you? 福井 洋(@echizenya_yota) https://twitter.com/echizenya_yota http://e-yota.com/ WordCamp Kyoto 2017
実行委員(スポンサーチーム担当) https://2017.kyoto.wordcamp.org/organizers/ http://e-yota.com/webservice/suponsors-organizer/ 普段はWordPressサイトのサーバー構築のお手伝いと個人レッスン、Web初心者向け にプログラミングの個人レッスンをしている個人事業主です。
WordCamp Kyoto 2017 コントリデイ 本日のネタはwckyoto2017の2日目に行われたコントリビュターデイで、WordPress Codexを編集したときの内容に基づいてお話します。
実際に自分が編集したところ
register_activation_hook関数とは プラグインが有効化されたときに実行される関数を登録する関数。
register_activation_hook関数の具体例 class WPWA_User_Manager { public function __construct() { // 初期化コード
register_activation_hook( __FILE__ , array( $this, 'add_application_user_roles' ) ); } public function add_application_user_roles() { add_role( 'follower', 'Follower', array( 'read' => true ) ); add_role( 'developer', 'Developer', array( 'read' => true ) ); add_role( 'member', 'Member', array( 'read' => true ) ); } } $user_manage = new WPWA_User_Manager(); 詳しくはこちら→ https://goo.gl/Y83PGS プラグインが有効化されたときに、 Follower、Developper、Memberと いうユーザーロールが追加される
register_activation_hook関数の2つの使い方 • 関数を使う場合(クラスメソッドを使わない場合) • 関数を使わない場合(クラスメソッドを使う場合) →今回は関数を使わない場合(クラスメソッドを使う場合)でPHP の文法について説明
オブジェクトとは? class Hoge { public function __construct() { wp_example(__FILE__, array(
$this, 'fuga' ) ); } public function fuga() { } } →データとデータの処理方法の定義書 (説明の便宜上、架空のWordPress関数、wp_exampleを使用します)
クラス定義 class Hoge { } →定義するクラス名を宣言
コンストラクタ(初期化処理) class Hoge { public function __construct() { wp_example(__FILE__, array(
$this, 'fuga' ) ); } } →Hogeクラスが実行されると必ず__construct()というメソッドが呼び出される
__FILE__(マジック定数) class hoge { public function __construct() { // 初期化コード
wp_example(__FILE__, array( $this, 'fuga' ) ); } } →ファイルのフルパスとファイル名。 自分の環境だと/var/www/wordpress/wp-content/plugins/wpwa-user-manager/class-wpwa-user-manager.php と言う意味。
配列 class Hoge { public function __construct() { // 初期化コード
wp_example(__FILE__, array( $this, 'fuga' ) ); } } →変数を複数入れられる「箱」のようなもの
擬似変数 class Hoge { public function __construct() { // 初期化コード
wp_example(__FILE__, array( $this, 'fuga' ) ); } } →クラスの中のメソッドやプロパティ(クラス変数)みたいにアクセスする時に使うキー ワード
メソッド class Hoge { public function __construct() { // 初期化コード
wp_example( __FILE__ , array( $this, ‘fuga’) ); } public function fuga() { echo “My Name is Wapuu!”; } } →クラス内で使う関数
インスタンス化とは? class Hoge { public function __construct() { wp_example(__FILE__, array(
$this, 'fuga' ) ); } public function fuga() { echo “My Name is Wapuu!”; } } $hogefuga = new Hoge(); →クラスに定義されているデータを実際に持たせたデータ
newキーワード class Hoge { public function __construct() { wp_example(__FILE__, array(
$this, 'fuga' ) ); } public function fuga() { echo “My Name is Wapuu!”; } } $hogefuga = new Hoge(); →クラスに定義されている内容を実際に持たせたデータを呼び出す時に使うキーワード
オブジェクト変数 class Hoge { public function __construct() { wp_example(__FILE__, array(
$this, 'fuga' ) ); } public function fuga() { echo “My Name is Wapuu”; } } $hogefuga = new Hoge(); →クラスに定義されている内容を実際に持つ変数
オブジェクトとインスタンスの使用例 class Hoge { public function __construct() { wp_example(__FILE__, array(
$this, 'fuga' ) ); } public function fuga() { echo “My Name is Wapuu!”; } } $hogefuga = new Hoge(); $hogefuga->fuga(); →出力結果: My Name is Wapuu!
意味の分からない変数はデバッグしよう! class Hoge { public function __construct() { var_dump(__FILE__) exit;
wp_example(__FILE__, array( $this, 'fuga' ) ); } public function fuga() { echo “My Name is Wapuu!”; } } $hogefuga = new Hoge(); $hogefuga->fuga(); →出力結果: /var/www/wordpress/wp-content/plugins/wpwa-user-manager/class-wpwa-user-manager.php
公式ドキュメントを読もう! http://php.net/
本で調べよう! https://bookmeter.com/books/11600128
それでも分からなければdotinstallを利用しよう http://dotinstall.com/lessons/basic_php_v2
ご清聴ありがとうございました!