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
190
1
Share
はじめてのプラグインのつくりかた
WordBench 長野 vol.14 WordPress 勉強会 の登壇資料です。
Toro_Unit (Hiroshi Urabe)
December 02, 2017
More Decks by Toro_Unit (Hiroshi Urabe)
See All by Toro_Unit (Hiroshi Urabe)
ブロックテーマ、WordPress でウェブサイトをつくるということ / 2026.02.07 Gifu WordPress Meetup
torounit
0
620
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
570
ブロックテーマとこれからの WordPress サイト制作 / nishinomiya.dev@2025-12-21
torounit
1
280
ブロックテーマとこれからの WordPress サイト制作 / Toyama WordPress Meetup Vol.81
torounit
0
800
ブロックテーマ時代における、テーマの CSS について考える Toro_Unit / 2025.09.13 @ Shinshu WordPress Meetup
torounit
0
760
ブロックテーマでサイトリニューアルした話 / Toro_Unit / 2025.04.12 @ Shinshu WordPress Meetup
torounit
1
320
Cloudflare Meetup Nagano Vol.3
torounit
1
170
僕が考える 「HTML サイトを WordPress にする」話 / 2023-11-05 Kansai WordPress Meetup
torounit
9
8.7k
Cloudflare Pages に入門してみた / 2023-10-14 Cloudflare Meetup Nagano Vol.2
torounit
2
2.2k
Other Decks in Technology
See All in Technology
20260513_生成AIを専属DSに_AI分析結果の検品テクニック_ハンズオン_交通事故データ
doradora09
PRO
0
210
Anthropic「Long-running a gents」をGeminiで再現してみた
tkikuchi
0
800
サービスの信頼性を高めるため、形骸化した「プロダクションミーティング」を立て直すまでの取り組み
stefafafan
1
250
The 7 pitfalls of AI
ufried
0
200
AI駆動開発で生産性を追いかけたら、行き着いたのは品質とシフトレフトだった
littlehands
0
460
SLI/SLO、「完全に理解した」から「チョットデキル」へ
maruloop
1
140
ServiceによるKubernetes通信制御ーClusterIPを例に
miku01
1
160
AIが盛んな時代に 技術記事を書き始めて起きた私の中での小さな変化
peintangos
0
360
毎日の作業を Claude Code 経由にしたら、 ノウハウがコードになった
kossykinto
1
1.1k
Oracle Cloud Infrastructure presents managed, serverless MCP Servers for Oracle AI Database
thatjeffsmith
0
170
20260428_Product Management Summit_Loglass_JoeHirose
loglassjoe
4
7.3k
巨大プラットフォームを進化させる「第3のROI」
recruitengineers
PRO
2
2.5k
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
160
Navigating Team Friction
lara
192
16k
We Have a Design System, Now What?
morganepeng
55
8.1k
Faster Mobile Websites
deanohume
310
31k
Design in an AI World
tapps
1
210
Chasing Engaging Ingredients in Design
codingconduct
0
180
Joys of Absence: A Defence of Solitary Play
codingconduct
1
360
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
370
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
550
WENDY [Excerpt]
tessaabrams
10
37k
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