Skip to content

mootoons/wp-react-plugin-standard

Repository files navigation

Wordpress React Plugin Standard

ปลั๊กอินเริ่มต้นสำหรับ React ซึ่งมี Packages WP-script, React, ReactRouter, Eslint, Prettier, i18n

สำหรับ React Typescript WP React Typescript Plugin Standard


Quick Start BY NPM

# 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 

Quick Start BY Yarn

# 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 

รายละเอียดการปรับแต่งสำหรับงานของคุณเอง

Folder resources

  • สามารถแก้ไข alias import ได้ที่ไฟล์ jsconfig.json และ webpack.config.js

Folder app / search and replace

  • 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'); } }

ตัวอย่าง

MyApp-‹-Wordpress-Tester-—-WordPress