This loader is both simple and powerful. It does all the work of integrating and interacting with WordPress for you.
The only things you have left to do are tell him:
- The class that manages the plugin
- The class that build the administration (if needed)
- The action links that will be displayed in the Plugins area of WordPress (settings, documentation…)
The file header contains all the plugin information, in compliance with WordPress standards, which you just need to specify for your own needs.
As we saw in the class diagram, the loader WP_Sukellos_Basic_Plugin_Loader extends the WP_PLoad parent class. WP_PLoad is an abstract class that will force the implementation of a few methods :
- get_plugin() is used to return the reference to the plugin instance
- get_plugin_admin() is used to return the reference to the admin instance
- get_plugin_file() is the way to allow the WP_PLoad parent to retrieve plugin header information
All other methods are used to give the action links :
- get_update_url() is the URL used by WordPress to update the plugin
- get_settings_url() is the link for Settings
- get_documentation_url() is the link for Documentation
- get_support_url() is the link for Support
- get_sales_page_url() is the link for More plugins
Returning a blank value will disable the link display.
The loader class is a singleton, in order to restrict the instantiation to a single object. A Singleton is an object-oriented design pattern. Using Traits in PHP is handy for adding functionality to a class.
The use Singleton; line is a shortcut managed by Sukellos Fw. It makes it very easy to specify a class as a Singleton.