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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
610
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
560
ブロックテーマとこれからの 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
750
ブロックテーマでサイトリニューアルした話 / 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.6k
Cloudflare Pages に入門してみた / 2023-10-14 Cloudflare Meetup Nagano Vol.2
torounit
2
2.2k
Other Decks in Technology
See All in Technology
要件定義の精度を高めるための型と生成AIの活用 / Using Types and Generative AI to Improve the Accuracy of Requirements Definition
haru860
0
290
「SaaSの次の時代」に重要性を増すステークホルダーマネジメントの要諦 ~解像度を圧倒的に高めPdMの価値を最大化させる方法~
kakehashi
PRO
3
3.7k
Modernizing Your HCL Connections Experience: Visual Report to chain, Profile Enhancements, and AI Integration
wannesrams
0
280
EMから幅を広げるために最近挑戦していること / Recent challenges I'm undertaking to expand my horizons beyond EM
hiro_torii
1
180
多角的な視点から見たAGI
terisuke
0
120
Fabric MCPの紹介と使い分け
ryomaru0825
1
120
もっとコンテンツをよく構造化して理解したいので、LLM 時代こそ Taxonomy の設計品質に目を向けたい〜!
morinota
0
180
CyberAgent YJC Connect
shimaf4979
1
150
ハーネスエンジニアリング入門
knishioka
0
120
ファインディの事業拡大を支える 拡張可能なデータ基盤へのリアーキテクチャ
hiracky16
0
860
FessのAI検索モード:検索システムとLLMへの取り組み
marevol
0
270
AI駆動開発で生産性を追いかけたら、行き着いたのは品質とシフトレフトだった
littlehands
0
360
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
160
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
690
Navigating Team Friction
lara
192
16k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
380
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
330
RailsConf 2023
tenderlove
30
1.4k
Designing Powerful Visuals for Engaging Learning
tmiket
1
360
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
110
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