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
functions.phpからプラグインへ
Search
Ippei Sumida
February 26, 2021
Technology
2
790
functions.phpからプラグインへ
WP ZoomUP 59『はじめてのプラグイン作成』でお話ししたスライドです。
#WordPress #WPZoomUP
Ippei Sumida
February 26, 2021
Tweet
Share
More Decks by Ippei Sumida
See All by Ippei Sumida
AIで生成したものをAIでチェックしてる話
ippey
0
1.9k
『WordPressコミュニティで学ぶ』OSS貢献の多様性
ippey
0
620
25分で理解する!Symfonyの魅力とその実践的活用法
ippey
0
6.2k
素早いバリュー提供のための DROBEの新戦略
ippey
0
1.2k
Symfony 6.3のおすすめ新機能まとめ
ippey
1
1.7k
PhpStorm + GitHub Copilotはいいぞ
ippey
0
2.2k
それぞれの特徴から考えるフレームワーク選び
ippey
1
850
なるべくJavaScriptを書かないで SymfonyのUIをリッチにする Symfony UX
ippey
1
1.8k
はじめてのCI - 実践編 -
ippey
1
270
Other Decks in Technology
See All in Technology
マルチテナントのサービスインフラに大きなテナントを受け入れるまで
7474
0
410
Demystifying Vite Internals
nozomuikuta
2
210
とある事業会社にとっての Kaggler の魅力
hakubishin3
7
1.5k
生成AI入門
shukob
0
110
【完全版】Dify - LINE Bot連携 考え方と実用テクニック
uezo
3
850
外部カンファレンスで登壇しよう! 〜「強い」エンジニアへの一歩を踏み出す〜
logica0419
4
130
暴カワでビデオシンセサイザーを導入する技術
yuchi
2
120
RSGT Walk Through
kawaguti
PRO
2
370
Vue.js、Nuxtの機能を使い、 大量のコピペコードをリファクタリングする
igayamaguchi
3
800
SageMaker学習のツボ / The Key Points of Learning SageMaker
cmhiranofumio
0
270
Application Signalsで始めるSLO ユーザー満足度を数値化する第一歩
niftycorp
PRO
2
140
RAG: from dumb implementation to serious results
glaforge
0
610
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
327
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
40
2.1k
For a Future-Friendly Web
brad_frost
174
9.4k
Statistics for Hackers
jakevdp
796
220k
Code Reviewing Like a Champion
maltzj
519
39k
Faster Mobile Websites
deanohume
304
30k
Fireside Chat
paigeccino
32
3k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
26
700
Code Review Best Practice
trishagee
63
17k
No one is an island. Learnings from fostering a developers community.
thoeni
19
2.9k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Transcript
Ippei Sumida 2020.02.26 functions.php͔ΒϓϥάΠϯ ϓϥάΠϯΛ࡞ͬͯΈΑ͏
ϓϥάΠϯ ςʔϚ functions.php
ϓϥάΠϯ͖ͳΧελϚΠζ ɹɹςʔϚ͖ͳΧελϚΠζ
• จࣈͷ০ • ը૾ͷ০ʢnot Ճʣ • ϨΠΞτͷௐ • ςʔϚݻ༗ͷΧελϜϒϩοΫ •
ςʔϚͷઃఆ • ͦͷςʔϚͷΧελϚΠζ ςʔϚ͖ ςʔϚʹґଘ
• ཧը໘ͷΧελϚΠζ • αΠτઃఆɾػೳͷՃɾมߋ • γϣʔτίʔυ • ΧςΰϦ • ΧελϜϒϩοΫ
• REST API • ڞ௨ͳද੍ࣔޚ • ͦͷαΠτͷΧελϚΠζ ϓϥάΠϯ͖
ϓϥάΠϯ ςʔϚ functions.php ςʔϚʹؔΘΔ͜ͱ αΠτʹؔΘΔ͜ͱ
ϓϥάΠϯ ςʔϚ functions.php ςʔϚʹؔΘΔ͜ͱ αΠτʹؔΘΔ͜ͱ Ͳͬͪʹॻ͍ͯಈ͘
ͳͥϓϥάΠϯͳͷ͔
ςʔϚʹґଘ
ΧελϚΠζ ͠Α͏ʂ
ΧελϚΠζ ͠Α͏ʂ functions.php ࡞ɾमਖ਼ˍΞοϓϩʔυ
ΧελϚΠζ ͠Α͏ʂ functions.php
ΧελϚΠζ ͠Α͏ʂ functions.php ςʔϚA
ςʔϚม͍͑ͨʂ functions.php ςʔϚA
ςʔϚม͍͑ͨʂ functions.php ςʔϚB functions.php ςʔϚA
ςʔϚม͍͑ͨʂ functions.php ςʔϚB functions.php ςʔϚA ΧελϚΠζ͕ফ͑Δʂ
functions.php ίϐʔʂ functions.php ςʔϚB functions.php ίϐʔ
functions.php ίϐʔʂ functions.php ςʔϚB functions.php ίϐʔ ςʔϚBݻ༗ͷΧελϚΠζ͕ ফ͑Δʂ
ΧελϚΠζ ՕॴҠ২ʂ functions.php ςʔϚB functions.php Ҡ২
ΧελϚΠζ ՕॴҠ২ʂ functions.php ςʔϚB functions.php Ҡ২ ΧελϚΠζͨ͠Օॴ͚ͩ Ҡ২Ͱ͖Δࣗ৴͋Δʁ
None
ΧελϚΠζͯ͠ ࡞ͬͨؔ
ςʔϚͷؔΛ ͬͯΔ
ΧελϚΠζ ͠Α͏ʂ plugin.php ࡞ɾमਖ਼ˍΞοϓϩʔυ ϓϥάΠϯC
ΧελϚΠζ ͠Α͏ʂ plugin.php ϓϥΠϯC
ςʔϚม͍͑ͨʂ functions.php ςʔϚB functions.php ςʔϚA plugin.php ϓϥΠϯC αΠτʹӨڹͳ͠
functions.php͔Β ϓϥάΠϯ
ྫɿμογϡϘʔυɹɹ ɹɹΟδΣοτ
wp-content/themes/some-theme/functions.php
ϓϥάΠϯ ςʔϚ functions.php μογϡϘʔυͷΟδΣοτςʔϚ͕ มΘͬͯදࣔ͠ଓ͚ΔʰαΠτͷΧελϚΠζʱ ςʔϚʹؔΘΔ͜ͱ αΠτʹؔΘΔ͜ͱ
ͰΉ͔͍ͣ͠ΜͰ͠ΐʁ
ϓϥάΠϯ࡞ɺ࣮͜Μͳʹ؆୯ʂ MajiͰKantan 5εςοϓ 1.ϓϥάΠϯσΟϨΫτϦΛ࡞Δ 2.readme.txtΛࢦఆͷϑΥʔϚοτͰͭ͘Δ 3.[ϓϥάΠϯσΟϨΫτϦ໊].phpʹࢦఆͷϑΥʔϚοτͰίϝϯτΛॻ͘ 4.ίʔυΛॻ͘ •functions.phpͷίʔυΛΧοτˍϖʔετ͢Δ 5.ϓϥάΠϯσΟϨΫτϦΛΞοϓϩʔυ͢Δ •ߋ৽͍ͯ͠ΕɺςʔϚͷfunctions.phpΞοϓϩʔυ͢Δ
1. ϓϥάΠϯσΟϨΫτϦΛ࡞Δ
wp-content plugins dashboard-widget σΟϨΫτϦΛͭ͘Δʂ ऴ ੍࡞ɾஶ࡞ ━━━━━ ⡹⡲⡼
•wp-content/plugins/ ʹ͓Έͷ໊͓લͰ •খจࣈͱϋΠϑϯͱࣈͷΈ߹Θ͕ͤແ •ඞͣҰҙʹͳΔΑ͏ʹʂʂ wp-content plugins dashboard-widget σΟϨΫτϦΛͭ͘Δʂ ิ
2. readme.txtΛͭ͘Δ
ެࣜʹαϯϓϧ͋Δ
3. PHPʹίϝϯτΛॻ͘
wp-content plugins dashboard-widget σΟϨΫτϦͱಉҰ໊ͷPHPϑΝΠϧΛ࡞Δ dashboard-widget.php
࠷ݶ͜Ε͚ͩʂ
ެࣜʹαϯϓϧ͋Δ
4. ίʔυΛॻ͘ લʹ
PHPίʔσΟϯάنΛकΖ͏ʂ WordPressʹίʔσΟϯάنʢ= ॻ͖ํʣ͕͋ΓɺͦΕʹैͬͯ ίʔσΟϯά͢Δඞཁ͕͋Γ·͢ɻॻ͖ํ͕౷Ұ͞ΕͨίʔυՄಡ ੑ͕ൈ܈ʹ্͕Γ·͢ɻʢ※ 3ϲ݄લͷࣗଞਓʣ ίʔσΟϯάنHTML, CSS, JavaScript, PHP͝ͱʹܾ·͍ͬͯ·
͢ɻެࣜͷυΩϡϝϯτʹهड़ํ๏͕ެ։͞Ε͍ͯ·͢ɻ
ؓٳ ※ ݸਓͷײͰ͢
ϑϨʔϜϫʔΫ ίʔσΟϯάن Laravel PSR-2 Symfony PSR-12 (PSR-2ͷ֦ு) ϕʔε CakePHP PSR-2
Yii PSR-2 ओཁPHPϑϨʔϜϫʔΫͷίʔσΟϯάن
PSR PHP Standard Recommendation
PHP-FIG PHP Framework Interoperability Group
PHPʹؔ͢Δʰ͓࡞๏ʱΛܾΊ͍ͯΔάϧʔϓ https://www.php- fi g.org
࠷ۙͷPHP΄ͱΜͲɺ PSR-2͔PSR-12
WordPressʁ
ಠࣗ
None
None
ͳΜͰʁ
ؓٳ͓ΘΓ
4. ίʔυΛॻ͘
wp-content/themes/some-theme/functions.php
wp-content/themes/some-theme/functions.php ʘ Χοτ! ʗ
wp-content/plugins/dashboard-widget/dashboard-widget.php
ʘ ϖʔετ! ʗ wp-content/plugins/dashboard-widget/dashboard-widget.php
ऴ ੍࡞ɾஶ࡞ ━━━━━ ⡹⡲⡼
ิ
wp-content/plugins/tutorial-widget/tutorial-widget.php ҰҙʹͳΔΑ͏ʹʂ ※಄ࣙʹϓϥάΠϯ໊ೖΕΔͱΑ͍ ※Ϋϥεͷϝιου໊ͷͧ͘
5. Ξοϓϩʔυ͢Δ લʹ
ಈ࡞֬ೝͯ͠Ξοϓϩʔυ͍ͨ͠
wp-env @wordpress/env
WordPress։ൃڥΛ αΫοͱ࡞Δʔͭ Hi!
http://localhost:8888 ID: admin PW: password ΅͘yarnʂ
wp-envͷ͕͜͜ਪ͠ϙΠϯτ • ϩʔΧϧʹnpmʢyarnʣͱDocker͕͋Ε͍͍ • ෳϓϩδΣΫτ͋ͬͯɺผѻ͍Ͱ͖Δ • ʢ࡞࣌ʣৗʹ·ͬ͞Β • ͍ͭͰ͜ΘͤΔ •
Dockerͷϩΰ͔Θ͍͍ • yarn͔Θ͍͍ υϠΝ!
ࣗಈͰΠϯετʔϧࡁΈ ཁΞΫςΟϕʔτ
None
5. Ξοϓϩʔυ͢Δ
wp-content plugins dashboard-widget σΟϨΫτϦΛ·ΔͬͱΞοϓϩʔυʂ dashboard-widget.php
wp-content themes some-theme functions.phpΛίϐϖͯͨ͠ΒςʔϚ functions.php
ཁΞΫςΟϕʔτ
None
ࢀߟɿ΅͘ͳΒ
None
͜͏࡞Δ
͕࣌ؒ͋Εઆ໌
Conclusion • functions.phpʹςʔϚͷΧελϚΠζɺ ϓϥάΠϯʹαΠτͷΧελϚΠζΛهड़͢Δ • ϓϥάΠϯ࡞ʹඞཁͳͷɺͨͬͨͷ5εςοϓ • ίʔσΟϯάنΛकΖ͏ • άϩʔόϧͳͷʹҰҙͳ໊લΛ͚ͭΔ
• wp-envਆɻςʔϚ࡞ʹ͑ΔΑ
֯ా Ұฏ Web Developer Freelance @ippey_s ͢Έͩɹ͍͍ͬ