Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
はじめてのプラグインのつくりかた
Search
Toro_Unit (Hiroshi Urabe)
December 02, 2017
Technology
1
190
はじめてのプラグインのつくりかた
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)
ブロックテーマとこれからの WordPress サイト制作 / Toyama WordPress Meetup Vol.81
torounit
0
580
ブロックテーマ時代における、テーマの CSS について考える Toro_Unit / 2025.09.13 @ Shinshu WordPress Meetup
torounit
0
410
ブロックテーマでサイトリニューアルした話 / Toro_Unit / 2025.04.12 @ Shinshu WordPress Meetup
torounit
1
270
Cloudflare Meetup Nagano Vol.3
torounit
1
130
僕が考える 「HTML サイトを WordPress にする」話 / 2023-11-05 Kansai WordPress Meetup
torounit
9
7.9k
Cloudflare Pages に入門してみた / 2023-10-14 Cloudflare Meetup Nagano Vol.2
torounit
2
2k
ブロックエディタをゴリゴリに使い倒してサイトを作った話 / Kansai WordPress Meetup 2023 09 23
torounit
15
10k
ブロックエディターカスタマイズことはじめ #wpshinshu / 2023-06-17 Shinshu WordPress Meetup vol.24
torounit
1
440
FSE時代におけるWEBサイト制作の研究 #wpshinshu / 2023-05-20 Shinshu WordPress Meetup vol.23
torounit
0
480
Other Decks in Technology
See All in Technology
AWS Security Agentの紹介/introducing-aws-security-agent
tomoki10
0
300
「Managed Instances」と「durable functions」で広がるAWS Lambdaのユースケース
lamaglama39
0
330
ガバメントクラウド利用システムのライフサイクルについて
techniczna
0
190
Lessons from Migrating to OpenSearch: Shard Design, Log Ingestion, and UI Decisions
sansantech
PRO
1
140
エンジニアとPMのドメイン知識の溝をなくす、 AIネイティブな開発プロセス
applism118
4
1.3k
.NET 10の概要
tomokusaba
0
110
Sansanが実践する Platform EngineeringとSREの協創
sansantech
PRO
2
900
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
因果AIへの招待
sshimizu2006
0
980
Lookerで実現するセキュアな外部データ提供
zozotech
PRO
0
150
Lambdaの常識はどう変わる?!re:Invent 2025 before after
iwatatomoya
1
600
regrowth_tokyo_2025_securityagent
hiashisan
0
250
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Statistics for Hackers
jakevdp
799
230k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.5k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
The Pragmatic Product Professional
lauravandoore
37
7.1k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The Language of Interfaces
destraynor
162
25k
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