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
はじめてのプラグインのつくりかた
Search
Toro_Unit (Hiroshi Urabe)
December 02, 2017
Technology
1
180
はじめてのプラグインのつくりかた
WordBench 長野 vol.14 WordPress 勉強会 の登壇資料です。
Toro_Unit (Hiroshi Urabe)
December 02, 2017
Tweet
Share
More Decks by Toro_Unit (Hiroshi Urabe)
See All by Toro_Unit (Hiroshi Urabe)
ブロックテーマ時代における、テーマの CSS について考える Toro_Unit / 2025.09.13 @ Shinshu WordPress Meetup
torounit
0
160
ブロックテーマでサイトリニューアルした話 / Toro_Unit / 2025.04.12 @ Shinshu WordPress Meetup
torounit
1
230
Cloudflare Meetup Nagano Vol.3
torounit
1
110
僕が考える 「HTML サイトを WordPress にする」話 / 2023-11-05 Kansai WordPress Meetup
torounit
9
7.7k
Cloudflare Pages に入門してみた / 2023-10-14 Cloudflare Meetup Nagano Vol.2
torounit
2
1.9k
ブロックエディタをゴリゴリに使い倒してサイトを作った話 / Kansai WordPress Meetup 2023 09 23
torounit
15
10k
ブロックエディターカスタマイズことはじめ #wpshinshu / 2023-06-17 Shinshu WordPress Meetup vol.24
torounit
1
420
FSE時代におけるWEBサイト制作の研究 #wpshinshu / 2023-05-20 Shinshu WordPress Meetup vol.23
torounit
0
470
ブロックエディターを用いたWEBサイト開発とカスタムフィールドのあり方を考える。/ WordCamp Japan 2021
torounit
0
580
Other Decks in Technology
See All in Technology
AI Agentと MCP Serverで実現する iOSアプリの 自動テスト作成の効率化
spiderplus_cb
0
500
実装で解き明かす並行処理の歴史
zozotech
PRO
1
420
Large Vision Language Modelを用いた 文書画像データ化作業自動化の検証、運用 / shibuya_AI
sansan_randd
0
110
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
9k
Flaky Testへの現実解をGoのプロポーザルから考える | Go Conference 2025
upamune
1
430
KMP の Swift export
kokihirokawa
0
330
Green Tea Garbage Collector の今
zchee
PRO
2
390
E2Eテスト設計_自動化のリアル___Playwrightでの実践とMCPの試み__AIによるテスト観点作成_.pdf
findy_eventslides
1
410
about #74462 go/token#FileSet
tomtwinkle
1
360
Azure SynapseからAzure Databricksへ 移行してわかった新時代のコスト問題!?
databricksjapan
0
140
JAZUG 15周年記念 × JAT「AI Agent開発者必見:"今"のOracle技術で拡張するAzure × OCIの共存アーキテクチャ」
shisyu_gaku
0
110
Trust as Infrastructure
bcantrill
0
340
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.5k
GitHub's CSS Performance
jonrohan
1032
460k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
Designing Experiences People Love
moore
142
24k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
The Invisible Side of Design
smashingmag
301
51k
Building an army of robots
kneath
306
46k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
19
1.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Transcript
͡ΊͯͷϓϥάΠϯͷͭ͘Γ͔ͨ Toro_Unit @2017.12.02 / WordBench Nagano vol 14. 1
$ whoami ͜͡͠ΐ͏͔͍ 2
Toro_Unit ෦ ߛ (͏Β ͻΖ͠) ϑϦʔϥϯε Frontend Engineer / Web
Designer Plugin and Theme Developer Github: @torounit Twitter: @Toro_Unit Facebook: fb.me/torounit Blog: https://torounit.com 3
Plugins. • Custom Post Type Permalinks • Active installations: 90,000+
• Downloads: 450,000 + • Simple Post Type Permalinks • Powerful Posts Per Page (PPPP) • Responsive Slide • and more... 4
Vanilla — Free WordPress Themes 5
Contribution • WordBench ϞσϨʔλʔ • WordCamp Kyoto 2017 /
Kansai 2016 / Tokyo 2016 • WordCamp Tokyo 2017 Speaker • WordBench.org • VCCW Team • etc... 6
WordPress Plugins • WordPress Λ֦ு͢Δػೳɻ • ެࣜϨϙδτϦʹɺ50000 Ҏ্ͷ ϓϥάΠϯ͕ܝࡌ͞Ε͍ͯΔɻ(ཧ ը໘͔ΒΠϯετʔϧग़དྷΔͭ)
7
ͪΖΜࣗ࡞Ͱ͖Δɻ 8
ࣗ࡞͢ΔϝϦοτ • ϓϥάΠϯʹͨ͠ํ͕ɺ͍ճ͕͠༰қɻ • ςʔϚͷfunctions.php ʹॻ͘ͱͪ͝Όͪ͝Ό͢Δ͠ɺςʔϚ Λม͑Δͱͦͷػೳ͕ࢮ͵ɻࡶͳ࡞ΓํΛͯ͠ΔͱαΠτ͕ յΕΔɻ 9
ϓϥάΠϯͷͭ͘Γ͔ͨ 10
1. PHP ϑΝΠϧΛ࡞ͯ͠ɺwp-content/plugins ʹஔɻ • plugins Լʹ php ϑΝΠϧΛஔ͍ͯOK͕ͩɺϓϥάΠϯͷϑΝΠϧ͕૿͑ͨΓ͢ΔͷͰɺσΟϨΫτϦΛ࡞ͬͯͦͷதʹ ೖΕͨ΄͏͕Θ͔Γ͍͢ɻ
11
2.PHPϑΝΠϧͷઌ಄ʹίϝϯτΛهड़ <?php /* Plugin Name: ͍͢͝ϓϥάΠϯ Plugin URI: https://example.org Description:
͍ͧ͢͝ʔ Author: Toro_Unit Version: 1.0.0 Author URI: https://torounit.com/ License: GPL2 or Later. */ ࠷ݶ Plugin Name ͕͋ΕOK. 12
13
Ͱ͖ͨɻ 14
͓ΘΓ 15
ͱ͍͏Θ͚ʹ͍͔ͳ͍ͷͰ 16
ϓϥάΠϯΛͬͯɺWordPress ΛΧ ελϚΠζ͢Δɻ 17
Action Hooks Filter Hooks 18
ΞΫγϣϯϑοΫɾϑΟϧλʔϑοΫ • WordPress ͷಈ࡞Λมߋ͢ΔͨΊͷAPI • ΞΫγϣϯϑοΫɺಈ࡞ΛՃ͢Δɻ(දࣔͨ͠ΓɺDBʹ อଘͨ͠Γ) • ϑΟϧλʔϑοΫɺΛมߋ͢Δɻ 19
ϑΟϧλʔϑοΫͷྫ function sugoi_titie( $title ) { return '͍ͧ͢͝ʔ:' . $title;
} add_filter( 'the_title', 'sugoi_titie' ); 20
21
ΞΫγϣϯϑοΫͷྫ function sptp_admin_notices() { $message = '͍ͧ͢͝ʔɻ'; printf( '<div class="notice"><p>%s</p></div>',
$message ); } add_action( 'admin_notices', 'sptp_admin_notices'); 22
23
ϑοΫͷҰཡ 2700 ݸ͘Β͍͋Δɻ • wpdocs.osdn.jp/ϓϥάΠϯ_API/ΞΫγϣϯϑοΫҰཡ • wpdocs.osdn.jp/ϓϥάΠϯ_API/ϑΟϧλʔϑοΫҰཡ • developer.wordpress.org/reference/hooks/ 24
Shortcode API 25
γϣʔτίʔυͱɻ [gallery]ɹɺͷ[]ͰғΘΕͨϞϊɻίϨΛهࣄʹهड़͢Δͱ ͦͷγϣʔτίʔυʹม͞ΕΔɻ Contact Form 7 ͷϑΥʔϜίϨΛͬͯઃஔɻ [contact-form-7 id="1" title="͓͍߹ΘͤϑΥʔϜ"]
26
function sugoi_shortcode( $atts ) { $param = shortcode_atts( array( 'count'
=> 1, ), $atts ); return str_repeat( '͍͢͝', $param['count'] ); } add_shortcode( 'sugoi', 'sugoi_shortcode' ); 27
28
29
WordCamp Kansai ϋϯζΦϯΓ·ͨ͠ɻ ʮ͜ͷهࣄ˓ͰಡΊ·͢ʯϓϥάΠ ϯΛγϣʔτίʔυͰ࡞Δɻ wckansai2016/plugin-hands-on 30
ଞʹ༷ʑͳAPI WordPress API - WordPress Codex ຊޠ൛ μογϡϘʔυΟδΣοτ API/σʔλϕʔε API/HTTP
API/ ϑΝΠϧϔομʔ API/ϑΝΠϧγεςϜAPI/ϝλσʔλ API/ Options API/ϓϥάΠϯ API/ΫΠοΫλάAPI/Rewrite API/ Settings API/γϣʔτίʔυ API/Theme Modification API/ Theme Customization API/Transients API/WordPress Ο δΣοτ API 31
WP-CLI Λ͏ͱϓϥάΠϯͷͻͳܗΛαΫοͱ ࡞ΕΔ $ wp scaffold plugin my-plugin-name 32
Plugin Handbook ެࣜͷϓϥάΠϯͷυΩϡϝϯτɻӳޠ ͚ͩͲɺίʔυͷαϯϓϧͳͲଟ͍ͷ ͰͳΜͱ͔ͳΔɻ https://developer.wordpress.org/ plugins/ 33
ͱΓ͋͑ͣ • ීஈ͍ճ͍ͯ͠ΔίʔυΛϓϥάΠϯʹ͢Δͱ͜Ζ͔Βε λʔτͯ͠ΈΑ͏ɻ • ϑοΫͱɺγϣʔτίʔυ͕͑Δ͚ͩීஈͷαΠτ੍࡞ ʹ͍ͩͿཱͭɻ 34
ͭ·͍ͮͨΒ • αϙʔτϑΥʔϥϜͰฉ͍ͯΈΔɻ • ਓͷίʔυΛಡΜͰΈΔɻ • WordBench ͱ͔Ͱฉ͍ͯΈΔɻ 35
ࢀߟॻ੶ αΠτͷ֦ுੑΛඈ༂తʹߴΊΔ WordPressϓϥάΠϯ։ൃͷόΠϒϧ 36
Thanks! Github: @torounit Twitter: @Toro_Unit Facebook: fb.me/torounit Blog: https://torounit.com 37