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
830
functions.phpからプラグインへ
WP ZoomUP 59『はじめてのプラグイン作成』でお話ししたスライドです。
#WordPress #WPZoomUP
Ippei Sumida
February 26, 2021
Tweet
Share
More Decks by Ippei Sumida
See All by Ippei Sumida
DROBEの生成AI活用事例 with AWS
ippey
0
160
みんなでQAしてる話
ippey
0
90
AIで生成したものをAIでチェックしてる話
ippey
0
2k
『WordPressコミュニティで学ぶ』OSS貢献の多様性
ippey
0
830
25分で理解する!Symfonyの魅力とその実践的活用法
ippey
1
7k
素早いバリュー提供のための DROBEの新戦略
ippey
0
1.3k
Symfony 6.3のおすすめ新機能まとめ
ippey
1
1.9k
PhpStorm + GitHub Copilotはいいぞ
ippey
0
2.6k
それぞれの特徴から考えるフレームワーク選び
ippey
1
940
Other Decks in Technology
See All in Technology
ルートユーザーの活用と管理を徹底的に深掘る
yuobayashi
6
730
Riverpod & Riverpod Generatorを利用して状態管理部分の処理を書き換えてみる簡単な事例紹介
fumiyasac0921
0
110
17年のQA経験が導いたスクラムマスターへの道 / 17 Years in QA to Scrum Master
toma_sm
0
410
「家族アルバム みてね」を支えるS3ライフサイクル戦略
fanglang
1
270
Security response for open source ecosystems
frasertweedale
0
100
Enterprise AI in 2025?
pamelafox
0
100
KCD Brazil '25: Enabling Developers with Dapr & Backstage
salaboy
1
130
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
20k
AIエージェント完全に理解した
segavvy
4
280
DevOps文化を育むQA 〜カルチャーバブルを生み出す戦略〜 / 20250317 Atsushi Funahashi
shift_evolve
1
110
大規模サービスにおける カスケード障害
takumiogawa
2
290
Amazon EKS Auto ModeでKubernetesの運用をシンプルにする
sshota0809
0
110
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Building Adaptive Systems
keathley
41
2.5k
Embracing the Ebb and Flow
colly
85
4.6k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Designing Experiences People Love
moore
141
23k
Rails Girls Zürich Keynote
gr2m
94
13k
Designing for humans not robots
tammielis
251
25k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.6k
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 ͢Έͩɹ͍͍ͬ