ปลั๊กอินเริ่มต้นสำหรับ React ซึ่งมี Packages WP-script, React, ReactRouter, Eslint, Prettier, i18n
สำหรับ React Typescript WP React Typescript Plugin Standard
# Clone the Git repository
git clone https://github.com/mootoons/wp-react-plugin-standard.git
# Install node module packages
npm install
# Start development mode
npm start
# To run in production
npm run build
# Clone the Git repository
git clone https://github.com/mootoons/wp-react-plugin-standard.git
# Install by yarn module packages
yarn
# Start development mode
yarn start
# To run in production
yarn build
- สามารถแก้ไข alias import ได้ที่ไฟล์ jsconfig.json และ webpack.config.js
- my-app คือ text-domain และ filter key
- MyApp คือ namespace หรือ class name
- MY_APP_ คือ constants ต่างๆ ที่ใช้ในปลั๊กอิน
หากแก้ไขในส่วนของ folder app เรียบร้อยแล้วให้รันคำสั่ง
composer install && composer dumpautoload -o
ในส่วนของ php จะใช้ Method onHooks ในการเรียกใช้งานอัตโนมัติ
class Example
{
public function onHooks(): void
{
add_action('init', [$this, 'tester']);
}
public function tester(): void {
var_dump('Hello Tester');
}
}