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
820
functions.phpからプラグインへ
WP ZoomUP 59『はじめてのプラグイン作成』でお話ししたスライドです。
#WordPress #WPZoomUP
Ippei Sumida
February 26, 2021
Tweet
Share
More Decks by Ippei Sumida
See All by Ippei Sumida
みんなでQAしてる話
ippey
0
67
AIで生成したものをAIでチェックしてる話
ippey
0
2k
『WordPressコミュニティで学ぶ』OSS貢献の多様性
ippey
0
740
25分で理解する!Symfonyの魅力とその実践的活用法
ippey
1
6.7k
素早いバリュー提供のための DROBEの新戦略
ippey
0
1.3k
Symfony 6.3のおすすめ新機能まとめ
ippey
1
1.8k
PhpStorm + GitHub Copilotはいいぞ
ippey
0
2.4k
それぞれの特徴から考えるフレームワーク選び
ippey
1
890
なるべくJavaScriptを書かないで SymfonyのUIをリッチにする Symfony UX
ippey
1
1.9k
Other Decks in Technology
See All in Technology
#TRG24 / David Cuartielles / Post Open Source
tarugoconf
0
590
技術に触れたり、顔を出そう
maruto
1
150
My small contributions - Fujiwara Tech Conference 2025
ijin
0
1.4k
カップ麺の待ち時間(3分)でわかるPartyRockアップデート
ryutakondo
0
140
PaaSの歴史と、 アプリケーションプラットフォームのこれから
jacopen
7
1.5k
生成AI × 旅行 LLMを活用した旅行プラン生成・チャットボット
kominet_ava
0
160
Cloudflareで実現する AIエージェント ワークフロー基盤
kmd09
0
290
AWS Community Builderのススメ - みんなもCommunity Builderに応募しよう! -
smt7174
0
180
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
1.5k
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
180
When Windows Meets Kubernetes…
pichuang
0
310
Formal Development of Operating Systems in Rust
riru
1
420
Featured
See All Featured
Building Your Own Lightsaber
phodgson
104
6.2k
Become a Pro
speakerdeck
PRO
26
5.1k
Code Reviewing Like a Champion
maltzj
521
39k
Making Projects Easy
brettharned
116
6k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
210
Building Applications with DynamoDB
mza
93
6.2k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Building Adaptive Systems
keathley
38
2.4k
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 ͢Έͩɹ͍͍ͬ