Upgrade to Pro — share decks privately, control downloads, hide ads and more …

テーマレビューの現場から見た、抑えておくべきテーマ制作のセオリーと基礎知識

Toshihiro Kanai
September 14, 2018

 テーマレビューの現場から見た、抑えておくべきテーマ制作のセオリーと基礎知識

WordCamp Tokyo 2018 に登壇した際の資料です。

詳細は https://2018.tokyo.wordcamp.org/session/gh-2b/ をご覧ください。

Toshihiro Kanai

September 14, 2018
Tweet

More Decks by Toshihiro Kanai

Other Decks in Programming

Transcript

  1. ۚҪढ़ߒ NJSVDPO • ϑϦʔϥϯεͷ Web ΤϯδχΞ • ࠷ۙ͸ Vue.js ͳͲͷϑϩϯτΤϯυ͕ϝΠ

    ϯ • WordPress Core Contributor • WordPress ςʔϚ Coldbox ։ൃऀ • WordPress ςʔϚϨϏϡʔνʔϜϞσϨʔ λ • Twitter: @mirucons / Facebook & GitHub etc.: mirucon • https://www.mirucon.com/
  2. σΟϨΫτϦߏ੒ • ྫ͑͹͜Μͳײ͡ : my-theme/ L inc/ L customizer.php L

    related-posts.php L footer.php L functions.php L header.php L index.php L readme.txt L screenshot.png L single.php L style.css
  3. ςʔϚͰ͸ԿΛ͢Δ΂͖ • ςʔϚ͸݁ہϓϥάΠϯͱಉͨͩ͡ͷ PHP ϑΝΠϧͳͷͰɺ΍ Ζ͏ͱࢥ͑͹ԿͩͬͯͰ͖Δ • ͨͩ͠ςʔϚ͸ϓϥάΠϯͱҧͬͯ1͔ͭ͠༗ޮԽͰ͖ͳ͍ • ͦͷͨΊ

    WordPress.org ͷςʔϚσΟϨΫτϦͷཁٻࣄ߲Ͱ͸ ʮςʔϚ͸جຊతʹݟͨ໨Λ࢘Δ͜ͱͷΈ͢΂͖ʯͭ·Γɺ => ݟͨ໨ʹ௚઀ؔ܎ͳ͍ػೳΛςʔϚʹೖΕΔ΂͖Ͱ͸ͳ͍
  4. ςʔϚͰ͸ԿΛ͢Δ΂͖ • ͨͩ͜͠Ε͸ WordPress.org ͷςʔϚσΟϨΫτϦͷ࿩Ͱ͋Γɺଞͷςʔ Ϛ഑෍αΠτ౳Ͱ͸ҧͬͨΓ͢Δ • ݁ہ͸ݸʑͷػೳΛϓϥάΠϯԽ͢ΔͷͱɺςʔϚͰҰݩԽͯ͢͠΂ͯΛ ؅ཧ͢Δͷ͸ศར͞ͱͷτϨʔυΦϑ •

    ·ͨडୗ։ൃͳͲͰ͸ػೳࣗମʹ൚༻ੑ͕ͳ͍৔߹ɾͳΜΒ͔ͷࣄ৘ʹ ΑͬͯϓϥάΠϯΛ࢖͍ʹ͍͘৔߹ͳͲ΋͋Δ => ࣗ෼ͷ੍࡞͍ͯ͠Δ໨తɾެ։ൣғͳͲΛߟ͑ͯɺద੾ͳͱ͜ΖΛߟ͑ Α͏
  5. 8PSE1SFTT͸Φʔϓϯιʔε • WordPress ͸ຊମ͕Φʔϓϯιʔε • GPL ϥΠηϯεΛ࢖༻͍ͯ͠Δ • WordPress ͸ࢥ૝ͱͯ͠ʮύϒϦογϯάͷຽओԽ

    (Democratize publishing)ʯΛܝ͍͛ͯΔ • ΦʔϓϯιʔεͳͷͰ WordPress ͷ։ൃɾσΟεΧογϣϯɾ ຋༁ͳͲʹ͸୭Ͱ΋ߩݙͰ͖Δ
  6. ࠷େͷಛ௃ίϐʔϨϑτ • ίϐʔϨϑτͱ͸ɺ੍࡞෺ͷվม͞Εͨ΋ͷ΍೿ੜϓϩμΫτ (derivative work) ʹ΋ɺ΋ͱͷ੍࡞෺ͱಉҰͷࣗ༝ΛೝΊΔ΂͖ͱ͍͏ߟ͑ํ • WordPress ͷ৔߹ :

    • ΋ͱͷ੍࡞෺ = WordPress • ೿ੜϓϩμΫτ = ςʔϚɾϓϥάΠϯͳͲ => ͭ·ΓɺWordPress ͕ GPL Ͱ͋ΔݶΓɺ഑෍͢Δ࡞ͬͨςʔϚɾϓϥ άΠϯ΋ GPL ʹ͢Δٛ຿͕ൃੜ͢Δ
  7. @T VOEFSTDPSFT • Automattic ࣾ (JetPack ϓϥάΠϯͷ։ ൃͳͲΛ͍ͯ͠Δձࣾ) ͷ։ൃ͢Δε λʔλʔςʔϚ

    • ͔ͳΓத਎͸γϯϓϧͳ PHP ςϯϓ Ϩʔτ + CSS (SCSS) • γϯϓϧʹ཈͍͑ͨςʔϚʹಛʹ͓͢ ͢Ί
  8. ίʔσΟϯάن໿ • ίʔσΟϯάن໿͸ ίʔυͷॻ͖ํ ʹ͍ͭͯͷܾ·Γ͝ͱ • WordPress ʹ͸ WordPress Coding

    Standards ͱ͍͏ɺ WordPress ઐ༻ͷن໿͕͋Δ • ͜Ε͸ίʔυͷϑΥʔϚοτ͚ͩͰͳ͘ɺޙͰ৮ΕΔηΩϡϦ ςΟʹؔ͢Δ͜ͱ΋ؚ·ΕΔ
  9. ͳͥηΩϡϦςΟରࡦ͕ඞཁͳͷ͔ • ϓϩάϥϜʹ͸ʮಛผͳҙຯΛ࣋ͭจࣈྻʯ͕͋ͬͨΓ͢Δ • ·ͨ WordPress Ͱ͸ HTML Λѻ͏͜ͱ͕ଟ͘ɺHTML Λ࢖༻

    Ͱ͖Δ = JavaScript Λ࢖༻Ͱ͖Δ ͱ͍͏͜ͱͰ͋Γɺ JavaScript ʹ͸৭ʑͳ͜ͱ͕Ͱ͖ͯ͠·͏ͨΊɺѱ༻ͷڪΕ͕ ͋Δ
  10. ΫϩεαΠτεΫϦϓςΟϯά 944 • Ϣʔβʔ͕༧ظ͠ͳ͍ಈ࡞Λ͢Δίʔυ (ಛʹ JavaScript) Λಡ ΈࠐΉ͜ͱ • JavaScript

    Ͱ࣮ࡍʹͰ͖ͯ͠·͏͜ͱ : • উखʹଞͷαΠτ (ಛʹ΢Πϧε഑෍αΠτͳͲ) ʹసૹ • ౤ߘ಺༰Λॻ͖׵͑
  11. αχλΠζͷྫ • wp_kses() ؔ਺ • ڐՄ͢Δ HTML ͷΫϥεɾଐੑΛࢦఆ͠ɺڐՄ͞Εͳ͍΋ͷ Λ࡟আ͢Δ ྫ͑͹͜Μͳ

    HTML : ͜Μʹͪ͸ɺ<br/> <span class="my-class" style="color: red">ۚҪ</span>Ͱ͢ɻ
  12. wp_kses()ؔ਺ͷ࢖͍ํ $allowed_html = [ 'span' => [ 'class' => [],

    ], ]; $data = wp_kses( $data, $allowed_html );
  13. ςʔϚΧελϚΠβʔͱαχλΠζ $wp_customize->add_setting( 'credit_text', [ 'default' => '©2018 ͜ͷαΠτͷӡӦऀ', 'sanitize_callback' =>

    'wp_kses_post', ] ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'credit_text', [ 'label' => __( 'ΫϨδοτΛฤू', 'text-domain' ), 'section' => 'footer', 'type' => 'textarea', ] ) );
  14. Τεέʔϓͷྫ • esc_html() ؔ਺ => ͢΂ͯͷ HTML ΛϓϨʔϯςΩετԽ͢Δ ྫ͑͹͜Μͳ HTML

    : ͜Μʹͪ͸ɺ<br/> <span class="my-class" style="color: red">ۚҪ</span>Ͱ͢ɻ
  15. ςʔϚΛνΣοΫͰ͖ΔπʔϧɾϓϥάΠϯΛ࢖ ͏ • ςʔϚϢχοτςετ • Theme Check | WordPress.org •

    WPTRT/theme-sniffer: Theme Sniffer plugin using sniffs. • Debug Bar | WordPress.org
  16. ཁٻࣄ߲ • WordPress.org ςʔϚσΟϨΫτϦʹ͸ ཁٻࣄ߲ (Requirements) ͱ͍͏ɺܝࡌͷͨΊʹԊΘͳ͍ͱ͍͚ͳ͍ϧʔ ϧ͕͋Δ • ཁٻࣄ߲ͷৄࡉ͸ɺRequired

    – Theme Review Team — WordPress Λࢀর • ೔ຊޠ༁΋͋Γ·͢ : https://github.com/mirucon/required-ja