Hoặc viết dưới dạng plugin
This project was written as a demo application for an Envato Tuts+ Series on using Design Patterns in WordPressarrow-up-right.
This project is not an official WordPress plugin, theme, or application and is not meant to be run within the context of the WordPress application.
It's meant to provide a working example of the Simple Factory design pattern.
demo.php is the driver that is meant to be the entry-point of the application. It sets everything into motion.
demo.php
images contains a sketch of the Simple Factory Pattern diagram for this demo
images
lib contains the core files for the application
lib
lib/plugin.php represents the core plugin file or, more specifically, how you would incorporate the Simple Factory into a WordPress plugin.
lib/plugin.php
lib/simple-factory.php is the Simple Factory class itself that relies on a base class, its subclasses, and input to return the proper element
lib/simple-factory.php
lib/users/user.php the abstract base class representing all users
lib/users/user.php
lib/users/admin.php the subclass representing an Adminstrator with read-write privileges
lib/users/admin.php
read-write
lib/users/reader.php the subclass representing a Reader with read privileges
lib/users/reader.php
read
lib/users/volunteer.php the subclass representing a Volunteer with help privileges*
lib/users/volunteer.php
help
Download a copy of the latest tagarrow-up-right from GitHub
Extract the contents to a directory of your choice
Run the demo.php script from the command-line to see the script in action
Last updated 4 years ago