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

MW WP Form について語り尽くす

MW WP Form について語り尽くす

WordBench Fest.山口 -Spring WP Fever- 2017/05/20

Takashi Kitajima

May 21, 2017
Tweet

More Decks by Takashi Kitajima

Other Decks in Technology

Transcript

  1. ϞϯΩʔϨϯν IUUQTJODPSH 
 ΩλδϚλΧγ !JOD   ϑϦʔϥϯε
 8FCσβΠφʔϓϩάϥϚʔ 

    8PSE1SFTTϓϥάΠϯ
 .881'PSNɺ4NBSU$VTUPN'JFMET  8PSE1SFTTςʔϚ
 )BCBLJSJɺ.JNJ[VLV  4BTT$44ϑϨʔϜϫʔΫ
 #BTJT
  2.  ຋༁ϑΝΠϧͷಡΈࠐΈ  ֤ೖྗϑΟʔϧυͷಡΈࠐΈ  ֤όϦσʔγϣϯϧʔϧͷಡΈࠐΈ  .881'PSNΛ؅ཧ͢ΔΧελϜ౤ߘλΠϓΛొ࿥  ϝΠϯίϯτϩʔϥʔಡΈࠐΈ

     ςϯϓϨʔτͷಡΈࠐΈ௚લ UFNQMBUF@JODMVEF   ౤ߘσʔλɾςϯϓϨʔτ಺ʹ.881'PSNΛ࣮ߦ͢ΔͨΊͷγϣʔτίʔυ
 <NXGPSN@GPSNLFZ>ɺ<NXGPSN> ͕ଘࡏ͢Δ͔νΣοΫ  ଘࡏ͠ͳ͔ͬͨΒ͜͜Ͱ.881'PSNʹؔ͢Δॲཧ͸ऴྃ  γϣʔτίʔυΛ΋ͱʹͦͷϑΥʔϜͷઃఆΛऔಘ  ૹ৴σʔλΛ%#ʹҰ࣌తʹอଘ 5SBOTJFOU"1* $PPLJF   ϖʔδΩϟογϡΛແޮʹ͢ΔͨΊͷ)551ϔομʔΛग़ྗ  ૹ৴σʔλ͕ਖ਼͍͔͠νΣοΫ  $43'ରࡦͱͯ͠ૹ৴σʔλʹؚ·ΕΔτʔΫϯΛνΣοΫ  ૹ৴σʔλʹର͠όϦσʔγϣϯνΣοΫΛ࣮ߦ  ૹ৴σʔλɺόϦσʔγϣϯ݁ՌΛݩʹͲͷը໘Λදࣔ ϦμΠϨΫτ ͢Δ͔Λܾఆ  1045࣌ɺ΋͘͠͸ϦμΠϨΫτઌ͕ݱࡏͷ63-ͱҟͳΕ͹ϦμΠϨΫτΛ࣮ߦ ॳظԽɾجຊॲཧ ը໘දࣔͷͨͼʹ࣮ߦ Wݱࡏ
  3.  લड़ͷॳظԽॲཧΛ࣮ߦ  ࠷ॳʹදࣔ͢Δ΂͖ը໘ೖྗը໘ͳͷͰϦμΠϨΫτ͸ߦΘΕͳ͍  ֤ೖྗϑΟʔϧυͷγϣʔτίʔυΛొ࿥ BEE@TIPSUDPEF   ϖʔδදࣔ

    UIF@DPOUFOU    8PSE1SFTTͷը໘ද͕࣮ࣔߦɺ.881'PSNͷγϣʔτίʔυͷ࣮ߦ͕ߦΘΕɺ
 ϑΥʔϜ͕දࣔ͞ΕΔ  ֬ೝϘλϯԡԼ  ݱࡏදࣔதͷը໘ʹ1045  ૹ৴ϘλϯԡԼ  ݱࡏදࣔதͷը໘ʹ1045 ೖྗը໘ 1045 Wݱࡏ
  4.  લड़ͷॳظԽॲཧΛ࣮ߦ  @1045ʹ8PSE1SFTT΁ͷϦΫΤετ RVFSZ@WBST ͱಉ໊ͷΩʔؚ͕·Ε͍ͯΔ৔߹ɺ ͦͷRVFSZ@WBSTΛ࡟আ  ϑΝΠϧͷΞοϓϩʔυ͕͋Δ৔߹ɺϦμΠϨΫτͷલʹҰ࣌σΟϨΫτϦʹอଘ 

    όϦσʔγϣϯΤϥʔͳ͠  ֬ೝը໘΁ϦμΠϨΫτ  όϦσʔγϣϯΤϥʔ͋Γ  όϦσʔγϣϯΤϥʔը໘΁ϦμΠϨΫτ ೖྗը໘⒌ ϦμΠϨΫτ IUUQFYBNQMFDPN OBNFࢁాଠ࿠ ໊͓લɿ<NXGPSN@UFYUOBNFlOBNFz> Wݱࡏ
  5.  લड़ͷॳظԽॲཧΛ࣮ߦ  όϦσʔγϣϯΤϥʔͳ͠  ͦͷ··֬ೝը໘Λදࣔ  όϦσʔγϣϯΤϥʔ͋Γ  όϦσʔγϣϯΤϥʔը໘΁ϦμΠϨΫτ

     ֤ೖྗϑΟʔϧυͷγϣʔτίʔυΛొ࿥ BEE@TIPSUDPEF   ϖʔδදࣔ UIF@DPOUFOU    8PSE1SFTTͷը໘ද͕࣮ࣔߦɺ.881'PSNͷγϣʔτίʔυͷ࣮ߦ͕ߦΘΕɺ ϑΥʔϜ͕දࣔ͞ΕΔ  %#ʹҰ࣌తʹอଘͨ͠ૹ৴σʔλΛ࡟আ XQ@GPPUFS   ໭ΔϘλϯԡԼ  ݱࡏදࣔதͷը໘ʹ1045  ૹ৴ϘλϯԡԼ  ݱࡏදࣔதͷը໘ʹ1045 ֬ೝը໘ 1045 Wݱࡏ
  6.  લड़ͷॳظԽॲཧΛ࣮ߦ  @1045ʹ8PSE1SFTT΁ͷϦΫΤετ RVFSZ@WBST ͱಉ໊ͷΩʔؚ͕·Ε͍ͯΔ৔ ߹ɺͦͷRVFSZ@WBSTΛ࡟আ  όϦσʔγϣϯΤϥʔͳ͠ 

    ϝʔϧͷૹ৴ॲཧΛ࣮ߦ  ׬ྃը໘΁ϦμΠϨΫτ  όϦσʔγϣϯΤϥʔ͋Γ  όϦσʔγϣϯΤϥʔը໘΁ϦμΠϨΫτ ֬ೝը໘⒌ ϦμΠϨΫτ Wݱࡏ
  7.  લड़ͷॳظԽॲཧΛ࣮ߦ  όϦσʔγϣϯΤϥʔͳ͠  ͦͷ··׬ྃը໘Λදࣔ  όϦσʔγϣϯΤϥʔ͋Γ  όϦσʔγϣϯΤϥʔը໘΁ϦμΠϨΫτ

     ֤ೖྗϑΟʔϧυͷγϣʔτίʔυΛొ࿥ BEE@TIPSUDPEF   ϖʔδදࣔ UIF@DPOUFOU    8PSE1SFTTͷը໘ද͕࣮ࣔߦɺ.881'PSNͷγϣʔτίʔυͷ࣮ߦ͕ߦΘΕɺ
 ׬ྃը໘ϝοηʔδ͕දࣔ͞ΕΔ  %#ʹҰ࣌తʹอଘͨ͠ૹ৴σʔλΛ࡟আ XQ@GPPUFS ׬ྃը໘ Wݱࡏ
  8.  લड़ͷॳظԽॲཧΛ࣮ߦ  όϦσʔγϣϯΤϥʔ͋Γ  ͦͷ··όϦσʔγϣϯΤϥʔը໘Λදࣔ  ֤ೖྗϑΟʔϧυͷγϣʔτίʔυΛొ࿥ BEE@TIPSUDPEF 

     ϖʔδදࣔ UIF@DPOUFOU    8PSE1SFTTͷը໘ද͕࣮ࣔߦɺ.881'PSNͷγϣʔτίʔυͷ࣮ߦ͕ߦΘΕ
 ϑΥʔϜ͕දࣔ͞ΕΔ  %#ʹҰ࣌తʹอଘͨ͠ૹ৴σʔλΛ࡟আ XQ@GPPUFS όϦσʔγϣϯΤϥʔը໘ Wݱࡏ
  9. ಠࣗόϦσʔγϣϯϧʔϧͷ௥Ճ w ຊจϨϕϧ w ຊจϨϕϧ w ຊจϨϕϧ w ຊจϨϕϧ w

    ຊจϨϕϧ class MW_Validation_Rule_Foo extends MW_Validation_Rule { protected $name = ‘foo’; public function rule( $key, array $options = array() ) { if ( ΤϥʔʹͳΔ৚݅ ) { return ‘Τϥʔϝοηʔδ’; } } public function admin( $key, $value ) { ?> <label> <input type="checkbox" <?php checked( $value[$this->getName()], 1 ); ?> name="<?php echo MWF_Config::NAME; ?>[validation][<?php echo $key; ?>][<?php echo esc_attr( $this->getName() ); ?>]" value="1" /> όϦσʔγϣϯϧʔϧ໊ </label> <?php } } // ͜Ε͸কདྷతʹෆཁʹ͢Δ༧ఆ add_filter( 'mwform_validation_rules', function( $validation_rules ) { $validation_rules[‘foo’] = new MW_Validation_Rule_Foo(); return $validation_rules; } );
  10. ϑΥʔϜ಺༰ͷ਽ܗΛఆٛ͢Δ w $POUBDU'PSN͸ϑΥʔϜ࡞੒࣌ʹϑΥʔϜͷ਽ܗ͕ೖྗ͞ Ε͍ͯ·͕͢.881'PSN͸ͦ͏ͳ͍ͬͯ·ͤΜ w ඞཁͳํ͸ϑοΫͰ௥ՃͰ͖·͢ /** * ςʔϚ಺ inc/mw-wp-form-default-content.php

    Λ਽ܗͱͯ͠ར༻͢Δαϯϓϧ */ add_filter( 'mwform_default_content', function( $content ) { ob_start(); get_template_part( 'inc/mw-wp-form-default-content' ); return ob_get_clean(); } );